0
votes

I have a partial created for a symfony form, on some pages I want expanded to be set to true to display a radio. However on some pages I need a select option to be displayed which is achieved by setting expand to 'false'.

I know this is possible through a controller but it needs to be completed through twig.

1

1 Answers

0
votes

this seems to do the trick (Symfony 3.4, twig 2.11.3):

if your form:

'expanded' => true, 

and for rendering the field in template (setting the value to true/false depending on case):

{{ form_row(form.yourfield, {'expanded': false}) }}

Note that for some reason it didn't work when setting the "'expanded' => false" in the form definition and adjusting the value in twig to true after that (I didn't check more into that).