9

我正在我的 sf2 项目中构建一个表单,因此要提供我在 twig 中所做的输入:

{{ form_widget(form.price)  }}

输出是:

<input type="checkbox" value="1" required="required" 
       name="mybundle_appbundle_producttype[price]"
         id="mybundle_appbundle_producttype_price">

我的问题是:如何仅mybundle_appbundle_producttype_price在树枝中获取“id”的名称或内容?

因为对于每个字段,我都会在 Javascript 代码中使用 CSS id。

4

1 回答 1

32

您可以使用{{ dump(form.price) }}. 如果我没记错 id 可通过{{ form.price.vars.id }}

于 2013-08-11T04:37:04.153 回答