-1

I using symfony2.5. I change form field container div class.

generated form fields:

<div>                
     <label for="ddd" class="required">lname</label>
     <input type="text" id="acme_demobundle_default_lname" name="acme_demobundle_default[lname]"   required="required">
</div>

 <div>                
     <label for="dddd" class="required">fname</label>
     <input type="text" id="acme_demobundle_default_fname" name="acme_demobundle_default[fname]"   required="required">
</div>

I add class to there are input`s container div.

any idea thanks

Wouter J
  • 41,455
  • 15
  • 107
  • 112

2 Answers2

0

You can set attributes using the form builder inside your controller

$builder->add('lname', 'text', array('attr' => array('class'=>'something')))
yaloumi
  • 198
  • 1
  • 9
0

If you have this in your form:

$builder->add('name')

In your template you should use the functions:

{{ form_label(form.name) }} {# access the label #}
{{ form_widget(form.name) }} {# access the input field #}

You can wrap that up with your div and style it however you want:

<div class="your-class">
    {{ form_label(form.name) }}
    {{ form_widget(form.name) }}
</div>

You can check more on How to Customize Form Rendering