{% set filters_form_are_not_empty = false %}
    {% if filters_form is defined  %}
        <tr class="table-filters-line">
            {% if has_batch_actions %}
                <th></th>
            {% endif %}
            {% for field in fields ?? [] %}

                {% set field = field.getAsDto() %}
                {% if field.isDisplayedOn('index') %}
                    <th>
                    {% set field_property= field.property|replace({'.': "_"}) %}
                    {% if filters_form[field_property] is defined %}

                        {% set form_field = filters_form[field_property] %}

                        {% if form_field.vars.value is not null and form_field.vars.value is not empty %}{% set filters_form_are_not_empty = true %}{% endif %}
                        {% if "DateType" in field.formType or "DateTimeType" in field.formType %}
                            <div class="input-group input-group-sm">
                                <input type="text"
                                       class="form-control input-sm float-right date-range">
                                <div class="hidden date-time-range-fields"
                                     style="display: none;">
                                    {{ form_widget(form_field['dateStart'], {"attr" : {'class' : 'date-start', 'form': 'filters-form'}}) }}
                                    {{ form_widget(form_field['dateEnd'], {"attr" : {'class' : 'date-end', 'form': 'filters-form'}}) }}
                                </div>
                            </div>
                        {% else %}

                            <div class="form-widget input-group-sm">
                                {% set url = ea_url()
                                    .setController(ea.crudControllers.findCrudFqcnByEntityFqcn(ea.entity.fqcn))
                                    .setAction('autocompleteFilter')
                                    .setEntityId(null)
                                    .set('page',1)
                                    .unset('sort')
                                    .set('autocompleteContext', {
                                        'crudControllerFqcn': ea.crudControllers.findCrudFqcnByEntityFqcn(ea.entity.fqcn),
                                        'propertyName':  field.property,
                                        'originatingPage':  ea.crud.currentPage,
                                    })
                                    .generateUrl() %}

                                {% if not form_field.rendered %}
                                    {% if 'TextType' in field.formType  or  'IntegerType' in field.formType %}
                                        {{ form_widget(form_field, {'attr': {'autocomplete': 'off', 'data-lc-autocomplete-url' : url}|raw }) }}
                                    {% else %}
                                        {{ form_widget(form_field) }}
                                    {% endif %}
                                {% endif %}
                            </div>
                        {% endif %}
                    {% endif %}
                {% endif %}


                </th>
            {% endfor %}
            <th class="actions">
                {{ form_widget(filters_form.action_apply) }}
                {% if filters_form_are_not_empty %}
                    {{ form_widget(filters_form.action_reset) }}
                {% else %}
                    {% do filters_form.action_reset.setRendered %}
                {% endif %}
            </th>
        </tr>
    {% endif %}

