user3872036
user3872036

Reputation: 41

Symfony FormBuilder SetAttribute not working

Symfony2 formBuilder setAttribute not working.

When getAttributes return right value.

But at render it doesn't take effect

like

$form=$this->createFormBuilder();
$form->setAttribute('name','thename');  
$form=$form->getForm();
return $this->render('AcmeDemoBundle:Form:testingForm.html.twig',array('testingForm'=>$form->createView() ));   

Upvotes: 2

Views: 2497

Answers (1)

Tom
Tom

Reputation: 1223

I had the same problem. Neither setAttribute nor setAttributes works.

So I pass options like this:

$this->createFormBuilder(null, array(
    'attr' => array(
          'class' => 'delete-action-form'
    )
));

Check the docs

Upvotes: 4

Related Questions