Customize widget's ID attribute in Twig

前端 未结 3 522
南旧
南旧 2021-01-04 00:50

Is it possible to customize HTML \'id\' attribute in Twig when rendering a widget with {{ form_widget(form.NAME_OF_THE_FIELD) }} ?

Passing {\'attr

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 01:03

    {{ form_widget(form.title, { 'attr': {'id': 'my_id'} }) }}
    

    http://symfony.com/doc/current/book/forms.html

    I have used it and it works.

提交回复
热议问题