Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get name of css ID in a form in twig

Tags:

html

twig

symfony

I'm building a form in my sf2 project,so to provide a input I do in 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?

Because for every field I'll use the CSS id in Javascript code.

like image 678
Nabilovish Bennani Avatar asked Aug 11 '13 03:08

Nabilovish Bennani


1 Answers

You can get all possible params with {{ dump(form.price) }}. If I remember correctly id accessable via {{ form.price.vars.id }}

like image 184
Alexey B. Avatar answered Sep 27 '22 17:09

Alexey B.