You are here

select--gin-lb.html.twig in Gin Layout Builder 1.0.x

Theme override for a select element.

Available variables:

  • attributes: HTML attributes for the <select> tag.
  • options: The <option> element children.

File

templates/form/select--gin-lb.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override for a select element.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the <select> tag.
  8. * - options: The <option> element children.
  9. *
  10. * @see template_preprocess_select()
  11. */
  12. #}
  13. {% apply spaceless %}
  14. <select{{ glb_classes(attributes.addClass('form-element').addClass('form-element--type-select')) }}>
  15. {% for option in options %}
  16. {% if option.type == 'optgroup' %}
  17. <optgroup label="{{ option.label }}">
  18. {% for sub_option in option.options %}
  19. <option value="{{ sub_option.value }}"{{ sub_option.selected ? ' selected="selected"' }}>{{ sub_option.label }}</option>
  20. {% endfor %}
  21. </optgroup>
  22. {% elseif option.type == 'option' %}
  23. <option value="{{ option.value }}"{{ option.selected ? ' selected="selected"' }}>{{ option.label }}</option>
  24. {% endif %}
  25. {% endfor %}
  26. </select>
  27. {% endapply %}