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

后端 未结 5 1939
小鲜肉
小鲜肉 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 11:09

    If you're using Symfony 3.1, the field types have changed to use their explicit class (FormType, TextType, and EmailType) and the parameter position for the value of the form name attribute has switched places with the FormType parameter in the createNamedBuilder function.

    $this->get('form.factory')
      ->createNamedBuilder('form_name', FormType::class, $defaultData)
      ->add('name', TextType::class)
      ->add('email', EmailType::class)
      ->getForm();
    

提交回复
热议问题