Skip to content
Snippets Groups Projects
Commit d90a8f06 authored by Kevin Paxman's avatar Kevin Paxman
Browse files

Merge branch 'feature/ISTWCMS-5946-m26lebla-cleanup-text-area-select-css' into '1.1.x'

ISTWCMS-5946: adding twig logic to add size to attributes array for select

See merge request !88
parents 9d9390a5 0f2c5525
No related branches found
No related tags found
1 merge request!88ISTWCMS-5946: adding twig logic to add size to attributes array for select
{#
/**
* @file
* Default theme implementation for a select element.
*
* Available variables:
* - attributes: HTML attributes for the <select> tag.
* - options: The <option> element children.
*
* @see template_preprocess_select()
*
* @ingroup themeable
*/
#}
{# if size is not set, look at the options array and if < 4 then use for the size attribute #}
{% if not attributes.size and options|length < 4 %}
{% set attributes = attributes.setAttribute('size', options|length) %}
{% endif %}
{% apply spaceless %}
<select{{ attributes }}>
{% for option in options %}
{% if option.type == 'optgroup' %}
<optgroup label="{{ option.label }}">
{% for sub_option in option.options %}
<option value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
{% endfor %}
</optgroup>
{% elseif option.type == 'option' %}
<option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
{% endif %}
{% endfor %}
</select>
{% endapply %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment