I want to add a stylesheet class attribute to most of the fields, but not all.
public function buildForm(FormBuilder $builder, array $options) { $builder ->add('name_short', null, array('attr' => array('class' => 'rtl')) ) ->add('name_long') ->add('profile_education') ->add('profile_work') ->add('profile_political') ->add('twitter') ->add('facebook') ->add('website') ; }
Is there a simpler way than adding the attribute array('attr' => array('class' => 'rtl'))
to every field?
Was looking for something like looping the fields and setting the attribute after adding the field to the builder.
More like this (unfortunately there is no setOption method in FormBuilder):
foreach($builder->all() as $key => $value) { $value->setOption('attr', array('class' => 'rtl')); }
Thanks for any pointers.