0

I am trying to customize the template for the exposed filters of a view.

I have created the views-exposed-form.html.twig and Drupal loads it fine, following How do I theme exposed filters?.

For now, I have the standard code:

/**
 * @file
 * Theme override of a views exposed form.
 *
 * Available variables:
 * - form: A render element representing the form.
 *
 * @see template_preprocess_views_exposed_form()
 */
#}
{% if q is not empty %}
  {#
    This ensures that, if clean URLs are off, the 'q' is added first,
    as a hidden form element, so that it shows up first in the POST URL.
  #}
{{ q }}
{% endif %}
{{ form }}

and that works fine. Nevertheless, if I try to show only one field of the form (e.g., {{ form.field_city }}) nothing is shown in the filter block, though the page loads fine and there are no apparent errors.

I am working with Drupal 8.7.7 and PHP 7.3.9.

Any help will be more than welcome.

Thank you in advance.

  • You need {{ form|without('field1', 'field2', ...) }} at some point, excluding all fields you have already printed or don't want to print. – 4k4 Sep 25 '19 at 6:23
0

Solved. The problem seems to be an incompatibility with Better Exposed Filters module.

Thanks!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.