Created
August 18, 2016 22:51
-
-
Save thejimbirch/1cd31ee3b39ea4316ac3ca801be44141 to your computer and use it in GitHub Desktop.
Styling Exposed View Forms in Drupal 8 - Twig Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Theme override for a select element. | |
* | |
* Available variables: | |
* - attributes: HTML attributes for the select tag. | |
* - options: The option element children. | |
* | |
* @see template_preprocess_select() | |
*/ | |
#} | |
{% spaceless %} | |
<div class="select-style"> | |
<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> | |
</div> | |
{% endspaceless %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment