Adding classes to all form widgets in symfony

Posted by rlahay on Stack Overflow See other posts from Stack Overflow or by rlahay
Published on 2010-05-27T15:45:04Z Indexed on 2010/05/28 11:31 UTC
Read the original article Hit count: 287

Filed under:
|

Hi everyone, I am trying to find a better way to assign classes to form elements in symfony. Currently, I can't seem to get away from assigning each one manually. ie:

$this->widgetSchema['title']->setAttribute("class","fieldInput");
$this->widgetSchema['tag_line']->setAttribute("class","fieldInput");
$this->widgetSchema['description']->setAttribute("class","fieldInput");
// etc

Things I tried without success

1) looping through $this->widgetSchema, treating it as an array and setting attributes to each key

2) $this->widgetSchema->setAttribute() but this only applied the class to the label that was generated, not the form element

There must be a way to hit all the fields without specifically directing them?

Can anyone point me in the right direction?

© Stack Overflow or respective owner

Related posts about symfony

Related posts about symfony-forms