{% set form = _args.form %}
{% set sort_input = _args.sort_input %}
{% set dir_input = _args.dir_input %}
{% set _args = {
attr: {
id: '%s__table'|format(
form.vars.id
),
}|merge(_args.attr|default({})),
}|merge(_args) %}
{% set tbody = block('items') %}
{% embed '@ui2022/table.html.twig' with _args|filter((v,k) => (k not in ['form','sort_input','dir_input'])) %}
{% block items %}
{{ tbody|raw }}
{% endblock %}
{% endembed %}
<script type="text/javascript">
(function (window, document, $, undefined) {
$(function () {
$('#{{ _args.attr.id }}').on('click', 'th > a[data-sn-sort]', function (e) {
var $target = $(e.currentTarget);
$('#{{ sort_input.vars.id }}').val(
$target.attr('data-sn-sort')
);
$('#{{ dir_input.vars.id }}').val(
$target.attr('data-sn-sort-dir')
);
$('#{{ form.vars.id }}').submit();
e.preventDefault();
return false;
});
});
})(window, document, jQuery);
</script>