Symfony2, How to make a form label class/attr different than its input?

后端 未结 4 892
忘了有多久
忘了有多久 2021-01-30 05:31

I would like to build a form with label and inputs, but the class of them should be different. Code below creates the label for the input with same attr:

 publi         


        
4条回答
  •  余生分开走
    2021-01-30 05:56

    The above is no longer correct, at least in the context I was using it. In Symfony 2.1 the solution is:

    {{ form_label(form.item, label|default(null), { 'label_attr': { 'class': 'MYCLASS' } }) }}
    

提交回复
热议问题