How to set the name of a form without a class?

后端 未结 5 1951
小鲜肉
小鲜肉 2020-12-17 10:32

Here is written how to set the name of a form with a class:

http://symfony.com/doc/2.0/book/forms.html#creating-form-classes

but how to set the name of this

5条回答
  •  渐次进展
    2020-12-17 10:48

    There is no shortcut method for this purpose. Instead you have to access the method createNamedBuilder in the form factory:

    $this->get('form.factory')->createNamedBuilder('form', 'form_name', $defaultData)
        ->add('name', 'text')
        ->add('email', 'email')
        ->getForm();
    

提交回复
热议问题