Symfony2 - Twig : Set the default value in the dropdownlist

后端 未结 2 1215
梦谈多话
梦谈多话 2021-01-15 02:45

I have a Form in my twig template. One of the form fields is a dropdownlist that is created from an Entity in my form builder.

I would like to set the default value

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-15 03:30

    Ok, found my mistake, the code should be:

    {{ form_widget(form.type, {value: "28" } ) }}
    

    I forgot the quotes for the id. And also, there is a need to CTRL + F5 to refresh the page and see the difference.

提交回复
热议问题