You are here

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

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

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