You are here

bef-checkboxes.html.twig in Better Exposed Filters 8.4

{#
  Themes Views' default multi-select element as a set of checkboxes.

  Available variables:
    - wrapper_attributes: attributes for the wrapper element.
    - element: The collection of checkboxes.
    - children: An array of keys for the children of element.
    - is_nested: TRUE if this is to be rendered as a nested list.
    - depth: If is_nested is TRUE, this holds an array in the form of
      child_id => nesting_level which defines the depth a given element should
      appear in the nested list.
#}
{% set classes = [
  'form-checkboxes',
  'bef-checkboxes',
  is_nested ? 'bef-nested',
  show_select_all_none ? 'bef-select-all-none',
  show_select_all_none_nested ? 'bef-select-all-none-nested',
  display_inline ? 'form--inline'
] %}
<div{{ wrapper_attributes.addClass(classes) }}>
  {% set current_nesting_level = 0 %}
  {% for child in children %}
    {% set item = attribute(element, child) %}
    {% if is_nested %}
      {% set new_nesting_level = attribute(depth, child) %}
      {% include '@better_exposed_filters/bef-nested-elements.html.twig' %}
      {% set current_nesting_level = new_nesting_level %}
    {% else %}
      {{ item }}
    {% endif %}
  {% endfor %}
</div>

File

templates/bef-checkboxes.html.twig
View source
  1. {#
  2. Themes Views' default multi-select element as a set of checkboxes.
  3. Available variables:
  4. - wrapper_attributes: attributes for the wrapper element.
  5. - element: The collection of checkboxes.
  6. - children: An array of keys for the children of element.
  7. - is_nested: TRUE if this is to be rendered as a nested list.
  8. - depth: If is_nested is TRUE, this holds an array in the form of
  9. child_id => nesting_level which defines the depth a given element should
  10. appear in the nested list.
  11. #}
  12. {% set classes = [
  13. 'form-checkboxes',
  14. 'bef-checkboxes',
  15. is_nested ? 'bef-nested',
  16. show_select_all_none ? 'bef-select-all-none',
  17. show_select_all_none_nested ? 'bef-select-all-none-nested',
  18. display_inline ? 'form--inline'
  19. ] %}
  20. <div{{ wrapper_attributes.addClass(classes) }}>
  21. {% set current_nesting_level = 0 %}
  22. {% for child in children %}
  23. {% set item = attribute(element, child) %}
  24. {% if is_nested %}
  25. {% set new_nesting_level = attribute(depth, child) %}
  26. {% include '@better_exposed_filters/bef-nested-elements.html.twig' %}
  27. {% set current_nesting_level = new_nesting_level %}
  28. {% else %}
  29. {{ item }}
  30. {% endif %}
  31. {% endfor %}
  32. </div>