如何访问 views-exposed-form.html.twig 中的表单字段(公开过滤器)
How to access to form field in views-exposed-form.html.twig (exposed filters)
我正在尝试为视图的公开过滤器自定义模板。
我已经创建了 views-exposed-form.html.twig
并且 Drupal 加载它很好。现在,我有标准代码:
{#
/**
* @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 }}
而且效果很好。然而,如果我尝试只显示表单的一个字段(例如,twig {{ form.field_city }}
),过滤器块中不会显示任何内容,尽管页面加载正常并且没有明显的错误。
我正在使用 Drupal 8.7.7 和 PHP 7.3.9。
我们非常欢迎任何帮助。
提前致谢。
问题似乎是与 Better Exposed Filters 模块不兼容。
我正在尝试为视图的公开过滤器自定义模板。
我已经创建了 views-exposed-form.html.twig
并且 Drupal 加载它很好。现在,我有标准代码:
{#
/**
* @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 }}
而且效果很好。然而,如果我尝试只显示表单的一个字段(例如,twig {{ form.field_city }}
),过滤器块中不会显示任何内容,尽管页面加载正常并且没有明显的错误。
我正在使用 Drupal 8.7.7 和 PHP 7.3.9。
我们非常欢迎任何帮助。
提前致谢。
问题似乎是与 Better Exposed Filters 模块不兼容。