Get name css ID in form in twig

I create a form in my sf2 project, so for input I do in twig:

{{ form_widget(form.price) }} 

output:

 <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 "id" of only mybundle_appbundle_producttype_price in a branch?

Because for each field I will use the CSS identifier in the Javascript code.

+7
html symfony twig
source share
1 answer

You can get all possible parameters with {{ dump(form.price) }} . If I remember the identifier correctly, accessible through {{ form.price.vars.id }}

+28
source share

All Articles