Symfony twig how to add class to a form row

前端 未结 4 1507
情歌与酒
情歌与酒 2020-12-28 16:58

I am building a project in Symfony 2.3 using Twig. I want to add a class to the form row block. I am using a form theme file which contains:

{% block form_ro         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-28 17:39

    Docs say: you always able to pass attr to rendered element:

    {{ form_start(form, {'attr': {'class': 'your-class'}} ) }}
        {{ form_label(form, {'attr': {'class': 'your-class'}}) }}
        {{ form_widget(form, {'attr': {'class': 'your-class'}}) }}
        {{ form_errors(form, {'attr': {'class': 'your-class'}}) }}
    {{ form_end(form) }}
    

提交回复
热议问题