$context = $this->export_for_template_base($output);
$options = [];
+ // Standard option attributes.
+ $standardoptionattributes = ['text', 'value', 'selected', 'disabled'];
foreach ($this->_options as $option) {
if (is_array($this->_values) && in_array( (string) $option['attr']['value'], $this->_values)) {
$this->_updateAttrArray($option['attr'], ['selected' => 'selected']);
$o = [
'text' => $option['text'],
'value' => $option['attr']['value'],
- 'selected' => !empty($option['attr']['selected'])
+ 'selected' => !empty($option['attr']['selected']),
+ 'disabled' => !empty($option['attr']['disabled']),
];
+ // Set other attributes.
+ $otheroptionattributes = [];
+ foreach ($option['attr'] as $attr => $value) {
+ if (!in_array($attr, $standardoptionattributes) && $attr != 'class' && !is_object($value)) {
+ $otheroptionattributes[] = $attr . '="' . s($value) . '"';
+ }
+ }
+ $o['optionattributes'] = implode(' ', $otheroptionattributes);
$options[] = $o;
}
$context['options'] = $options;
];
}
+ // Standard option attributes.
+ $standardoptionattributes = ['text', 'value', 'selected', 'disabled'];
foreach ($this->_optGroups as $group) {
$options = [];
$o['selected'] = false;
}
$o['text'] = $option['text'];
+ $o['disabled'] = !empty($option['attr']['disabled']);
+ // Set other attributes.
+ $otheroptionattributes = [];
+ foreach ($option['attr'] as $attr => $value) {
+ if (!in_array($attr, $standardoptionattributes) && $attr != 'class' && !is_object($value)) {
+ $otheroptionattributes[] = $attr . '="' . s($value) . '"';
+ }
+ }
+ $o['optionattributes'] = implode(' ', $otheroptionattributes);
$options[] = $o;
}
$context = $this->export_for_template_base($output);
$options = [];
+ // Standard option attributes.
+ $standardoptionattributes = ['text', 'value', 'selected', 'disabled'];
foreach ($this->_options as $option) {
if (is_array($this->_values) && in_array( (string) $option['attr']['value'], $this->_values)) {
$this->_updateAttrArray($option['attr'], ['selected' => 'selected']);
$o = [
'text' => $option['text'],
'value' => $option['attr']['value'],
- 'selected' => !empty($option['attr']['selected'])
+ 'selected' => !empty($option['attr']['selected']),
+ 'disabled' => !empty($option['attr']['disabled']),
];
+ // Set other attributes.
+ $otheroptionattributes = [];
+ foreach ($option['attr'] as $attr => $value) {
+ if (!in_array($attr, $standardoptionattributes) && $attr != 'class' && !is_object($value)) {
+ $otheroptionattributes[] = $attr . '="' . s($value) . '"';
+ }
+ }
+ $o['optionattributes'] = implode(' ', $otheroptionattributes);
$options[] = $o;
}
$context['options'] = $options;
{{/error}}
{{element.attributes}} >
{{#element.options}}
- <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
+ <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}} {{{optionattributes}}}>{{text}}</option>
{{/element.options}}
</select>
{{/element.frozen}}
{{/error}}
{{element.attributes}} >
{{#element.options}}
- <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
+ <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}} {{{optionattributes}}}>{{text}}</option>
{{/element.options}}
</select>
{{/element.frozen}}
<optgroup label="{{text}}">
{{/text}}
{{#options}}
- <option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
+ <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}} {{{optionattributes}}}>{{{text}}}</option>
{{/options}}
{{#text}}
</optgroup>
<optgroup label="{{text}}">
{{/text}}
{{#options}}
- <option value="{{value}}" {{#selected}}selected{{/selected}}>{{{text}}}</option>
+ <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}} {{{optionattributes}}}>{{{text}}}</option>
{{/options}}
{{/element.optiongroups}}
{{#text}}
{{/error}}
{{element.attributes}} >
{{#element.options}}
- <option value="{{value}}" {{#selected}}selected{{/selected}}>{{text}}</option>
+ <option value="{{value}}" {{#selected}}selected{{/selected}} {{#disabled}}disabled{{/disabled}} {{{optionattributes}}}>{{text}}</option>
{{/element.options}}
</select>
{{/element.frozen}}