Some code first:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(
FormEvents::POST_SET_DATA,
function (FormEvent $event) {
/** @var Company $company */
$company = $event->getData();
$form = $event->getForm();
$form->add(
'paymentTerms',
'integer',
array(
'label' => 'Payment Terms',
'label_attr' => array(
'class' => 'col-sm-4 control-label'
),
'attr' => array(
'class' => 'form-control'
),
'error_bubbling' => true
)
);
}
)->setAction('test action')->setAttributes(array('class' => 'form-horizontal'));
}
Can someone explain why I can't seem to be able to add a css class to the form itself?
In the above example ->setAction('test action') works perfectly fine, but ->setAttributes(array('class' => 'form-horizontal')) doesn't have any effect on the form.
I've tried ->setAttribute('class', 'form-horizontal') as well with no luck. No errors, it's as if it's being ignored. Why?