php - Symfony adding style to each input field
I have a function, in Symfony2, that creates a form. Then I load it using twig and everything works fine.
The problem is that I would like to add style to each label and each input, separately, and I can only add style to the whole form.
private function createEditForm(Client $entity)
{
$form = $this->createForm(new ClientType(), $entity, array(
'action' => $this->generateUrl('client_update', array('id' => $entity->getId())),
'method' => 'PUT',
));
$form->add('submit', 'submit', array('label' => 'Update'));
return $form;
}
Could I do it the way I'm doing it or do I have to rebuild the function so it doesn't create the form dynamically from an array?
Thank you.
Answer
Solution:
You can customize the class rendered for example in your
ClientType
via something like this:Or you can add/override directly in your twig template as such:
For advanced cases and re-usability refer to the form customization tutorial here:
http://symfony.com/doc/current/cookbook/form/form_customization.html