【发布时间】:2013-01-29 12:53:13
【问题描述】:
我的树枝模板中有这个表格:
<form id="search-box" action="/search" method="get">
<input id="search-query" type="text" placeholder="Search..." name="search" role="textbox">
<a id="search-btn" href="....."></a>
</form>
我的目标是使用输入 id="search-query" 的值来为 a id="search-btn" 创建 href p>
为此,我必须访问输入 id="search-query" 的值。
我试过了:
{{ form.search-query.value }}
和
{{ search-box.search-query.value }}
但这些都不起作用。我收到表单或搜索不存在的错误。
有什么想法吗?
【问题讨论】:
-
您的表单类型是什么样的?
-
除了@iamdto 问题——你的表单是否甚至使用表单组件构建?
-
@thecatontheflat,不,唯一与表单有关的是表单 html 标记。此表单直接构建在 twig 文件中。