The built-in form creation function of symfony. After a form is created, it can be displayed directly in the template: {form_start (form) }{{ form_widget (form )}} {form_end (form)} Can I add a class to all the form elements to be created when I create a form? This... the built-in form creation function of symfony. After a form is created, it can be displayed directly in the template as follows:
{Form_start (form )}}
{Form_widget (form )}}
{Form_end (form )}}
Can I add a class to all the form elements to be created when I create a form? In this way, the front-end and front-end can better write styles. The following is the form creation code:
$ Task = new Task (); $ task-> setTask ('test form'); $ task-> setDueDate (new \ DateTime ('tomorrow ')); $ form = $ this-> createFormBuilder ($ task)-> add ('task', TextType: class)-> add ('duedate', DateType: class) -> add ('save', SubmitType: class, array ('label' => 'create task')-> getForm ();
Reply content:
The built-in form creation function of symfony. After a form is created, it can be displayed directly in the template as follows:
{Form_start (form )}}
{Form_widget (form )}}
{Form_end (form )}}
Can I add a class to all the form elements to be created when I create a form? In this way, the front-end and front-end can better write styles. The following is the form creation code:
$ Task = new Task (); $ task-> setTask ('test form'); $ task-> setDueDate (new \ DateTime ('tomorrow ')); $ form = $ this-> createFormBuilder ($ task)-> add ('task', TextType: class)-> add ('duedate', DateType: class) -> add ('save', SubmitType: class, array ('label' => 'create task')-> getForm ();
The form of Symfony can be rendered independently by each form component in the Twig template, and its own class (or other) attributes can be set as follows:
{{ form_start(form) }}{{ form_widget(form.field1, { 'attr': { 'class': 'class1' } }) }}{{ form_widget(form.field2, { 'attr': { 'class': 'class2' } }) }}{{ form_widget(form.field3, { 'attr': { 'class': 'class3' } }) }}{{ form_widget(form.field4, { 'attr': { 'class': 'class4' } }) }}{{ form_end(form) }}
$ Form = $ this-> createForm (new AnswerType (), new Answer (),[
'Action' => $ this-> generateUrl ('eb5 _ qas_reply', ['id' => $ id]), 'method' => 'post ', 'attr' => ['class' => 'form-horizontal ']); create the form attr attribute.