{# the html form view for the search form; expected to be of a SearchForm type #}
{% set form = _args.form %}
{% set headers = _args.headers %}
{% set pagination = _args.pagination|default(null) %}
{# use search form vars to generate sort data for the given headers #}
{% set headers = headers|map((header) => header|merge({
sort: (header.sort is defined and header.sort in form.vars.sorts) ? {
key: header.sort,
dir: (form.sort.vars.value is same as(header.sort)) ? form.direction.vars.value|dir_flip : form.vars.dirs[header.sort],
active: (form.sort.vars.value is same as(header.sort)),
} : null,
})) %}
{# render the content of the table; due to complexities with twig it needs done this way #}
{% set content = (block('items') is defined) ? block('items') : null %}
{# embed the sortable table view #}
{% embed '@ui2022/table--sortable.html.twig' with {
form: form,
sort_input: form.sort,
dir_input: form.direction,
header: {
labels: headers,
},
} %}
{% block items %}
{{ content|raw }}
{% endblock %}
{% endembed %}
{# add pagination if it is given #}
{% if pagination %}
{% include '@ui2022/pagination.html.twig' with pagination %}
{% endif %}