Apply class to Symfony2 Form Label

I’ve got it…

<?php 
    echo $view['form']->label($form['first_name'], 'First Name', array(
            'label_attr' => array('class' => 'control-label'),
         )) 
?>

Apparently “attr” is “label_attr” for labels fields.

P.S. Corresponding twig code

{{ form_label(form.first_name, 'First Name', { 'label_attr': {'class': 'control-label'} }) }}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)