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

后端 未结 4 900
忘了有多久
忘了有多久 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 06:08

    This works for me in Symfony 2.3:

    {{ form_row(form.hours,  {   'label': 'Hours:'
                                ,'label_attr': {'class': 'MYCLASSFOR_LABEL'}
                                ,'attr': {'class': 'MYCLASSFOR_INPUTS'} 
                            }
               )
    }}
    

提交回复
热议问题