Source of file GroupedListboxField.php
Size: 1,394 Bytes - Last Modified: 2021-12-24T06:39:34+00:00
/var/www/docs.ssmods.com/process/src/code/forms/GroupedListboxField.php
1234567891011121314151617181920212223242526272829303132333435 | <?php class GroupedListboxField extends ListboxField { public function Field($properties = array()) { if($this->multiple) $this->name .= '[]'; $options = ''; foreach($this->getSource() as $value => $title) { if(is_array($title)) { $options .= "<optgroup label=\"$value\">"; foreach($title as $value2 => $title2) { $selected = ((!is_array($this->value) && $this->value == $value2) || ((is_array($this->value) && in_array($value2, $this->value)) || in_array($value2, $this->defaultItems))) ? ' selected="selected"' : ''; $disabled = ($this->disabled || in_array($value2, $this->disabledItems)) ? 'disabled="disabled"' : ''; $options .= "<option$selected value=\"$value2\" $disabled>$title2</option>"; } $options .= "</optgroup>"; } else { // Fall back to the standard dropdown field $selected = ((!is_array($this->value) && $this->value == $value) || ((is_array($this->value) && in_array($value, $this->value)) || in_array($value, $this->defaultItems))) ? ' selected="selected"' : ''; $disabled = ($this->disabled || in_array($value, $this->disabledItems)) ? 'disabled="disabled"' : ''; $options .= "<option$selected value=\"$value\" $disabled>$title</option>"; } } return FormField::create_tag('select', $this->getAttributes(), $options); } public function Type() { return 'groupedlistbox listbox'; } } |