Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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() ));   
like image 924
user3872036 Avatar asked Nov 28 '25 09:11

user3872036


1 Answers

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

like image 147
Tom Avatar answered Nov 30 '25 00:11

Tom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!