Nabilovish Bennani Nabilovish Bennani - 6 months ago 14
HTML Question

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 :

{{ 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.

Answer

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

Comments