85 parent::__construct(
$name, $parameters, $form);
87 $this->list = (isset($parameters[
'list']) && is_array($parameters[
'list'])) ? $parameters[
'list'] : array();
88 $this->maxItems = isset($parameters[
'maxItems']) ? $parameters[
'maxItems'] :
$this->maxItems;
102 parent::setDefaults();
105 $this->defaults[
'defaultValue'] = array();
106 $this->defaults[
'skin'] =
'checkbox';
107 $this->defaults[
'maxItems'] =
null;
132 if (in_array($this->skin, [
'select',
'tags'])) {
133 foreach ($options as $index => $option) {
134 if (is_array($option)) {
135 $list .=
"<optgroup label=\"{$index}\">" . $this->
htmlList($option,
$value) .
"</optgroup>";
137 $selected = (in_array($index,
$value)) ?
' selected' :
'';
138 $list .=
"<option value=\"{$index}\"{$selected}>{$option}</option>";
145 foreach ($options as $index => $option) {
146 $selected = (is_array(
$value) && (in_array($index,
$value))) ?
" checked=\"yes\"" :
'';
150 "<input type=\"checkbox\" name=\"{$this->name}[]\"{$inputAttributes} value=\"{$index}\"{$selected}>" .
151 "<span>{$option}</span>" .
170 $label = $this->htmlLabel();
176 if (in_array($this->skin, [
'select',
'tags'])) {
181 return "<p {$wrapperAttributes}>" .
183 "<span class=\"depage-label\">{$label}{$marker}</span>" .
184 "<select multiple name=\"{$this->name}[]\"{$inputAttributes}>{$list}</select>" .
191 return "<p {$wrapperAttributes}>" .
192 "<span class=\"depage-label\">{$label}{$marker}</span>" .
193 "<span>{$list}</span>" .
213 if ($this->required && in_array($this->skin, [
'select',
'tags'])) $attributes .=
' required="required"';
214 if ($this->maxItems) $attributes .=
" data-max-items=\"$this->maxItems\"";
225 if ($this->value ==
"") {
226 $this->value = array();
228 $this->value = (array) $this->value;
230 if ($this->maxItems) {
231 $this->value = array_slice($this->value, 0, $this->maxItems);
htmlEscape($options=array())
Escapes HTML in strings and arrays of strings.
$value
Input elements's value.
$label
Input element - HTML label.
$errorMessage
Message that gets displayed in case of invalid input.
htmlHelpMessage()
Returns HTML-rendered helpMessage.
htmlWrapperAttributes()
Returns string of HTML attributes for element wrapper paragraph.
htmlMarker()
Returns elements' required-indicator.
$helpMessage
Extra help message.
htmlValue()
Returns HTML-rendered element value.
$marker
Input element - HTML marker text that marks required fields.
htmlErrorMessage()
Returns HTML-rendered error message.
HTML-multiple-choice input type i.e.
htmlInputAttributes()
Returns string of HTML attributes for input element.
htmlList($options=null, $value=null)
HTML option list rendering.
$list
Contains list of selectable options.
__construct($name, $parameters, $form)
multiple class constructor
$skin
HTML skin type (checkbox or select).
typeCastValue()
Converts value to element specific type.
__toString()
Renders element to HTML.
setDefaults()
collects initial values across subclasses.
Abstract element classes.
Classes for HTML input-elements.