twig - 如何访问 views-exposed-form.html.twig 中的表单字段(暴露的过滤器)
问题描述
我正在尝试为视图的公开过滤器自定义模板。
我已经创建了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 模块不兼容。
推荐阅读
- javascript - 等待 AJAX 调用时显示一次加载图标
- powerbi - 将多个文件转为一个
- php - 如何在 PHP 中解密由 SQL Server 的 EncryptByPassPhrase() 加密的字符串?
- winapi - 使用 IMetaDataEmit::Save(/ToMemory/ToStream) 创建 PE 文件
- dialogflow-es - 仅当用户来自 Google 审核团队时接收错误的 Contextname(使我的应用程序崩溃)
- azure - 有没有办法将 IIS 日志从 Log Analytics 工作区馈送到 App Insights?
- javascript - Window.locatin 防止数据被删除
- c# - 如何从 GridFS 检索图像列表?
- c# - 如何在 kubernetes 客户端中使用 Watcher?
- typescript - 根据 ID 显示其他 JSON 对象