[英]get name of css ID in a form in twig
I'm building a form in my sf2 project,so to provide a input I do in twig : 我正在我的sf2项目中构建一个表单,所以要提供我在twig中做的输入:
{{ form_widget(form.price) }}
the output is: 输出是:
<input type="checkbox" value="1" required="required"
name="mybundle_appbundle_producttype[price]"
id="mybundle_appbundle_producttype_price">
My question is: How to get the name or content of "id" only mybundle_appbundle_producttype_price
in twig? 我的问题是:如何在mybundle_appbundle_producttype_price
中获取“id”的名称或内容只有mybundle_appbundle_producttype_price
?
Because for every field I'll use the CSS id in Javascript code. 因为对于每个字段,我将在Javascript代码中使用CSS id。
You can get all possible params with {{ dump(form.price) }}
. 您可以使用{{ dump(form.price) }}
获取所有可能的参数。 If I remember correctly id accessable via {{ form.price.vars.id }}
如果我记得通过{{ form.price.vars.id }}
正确访问了id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.