@@ -144,14 +144,16 @@ helper functions:
144144 .. code-block :: html+jinja
145145
146146 {# app/Resources/views/Default/new.html.twig #}
147-
148- {{ form(form) }}
147+ {{ form_start(form) }}
148+ {{ form_widget(form) }}
149+ {{ form_end(form) }}
149150
150151 .. code-block :: html+php
151152
152153 <!-- app/Resources/views/Default/new.html.php -->
153-
154- <?php echo $view['form']->form($form) ?>
154+ <?php echo $view['form']->start($form) ?>
155+ <?php echo $view['form']->widget($form) ?>
156+ <?php echo $view['form']->end($form) ?>
155157
156158.. image :: /images/book/form-simple.png
157159 :align: center
@@ -162,12 +164,24 @@ helper functions:
162164 the same URL that it was displayed in. You will learn later how to
163165 change the request method and the target URL of the form.
164166
165- That's it! By printing ``form(form) ``, each field in the form is rendered, along
166- with a label and error message (if there is one). The ``form `` function also
167- surrounds everything in the necessary HTML ``<form> `` tag. As easy as this is,
168- it's not very flexible (yet). Usually, you'll want to render each form field
169- individually so you can control how the form looks. You'll learn how to do
170- that in the ":ref: `form-rendering-template `" section.
167+ That's it! Just three lines are needed to render the complete form:
168+
169+ * ``form_start(form) `` - Renders the start tag of the form, including the
170+ correct enctype attributes when using file uploads;
171+
172+ * ``form_widget(form) `` - Renders all fields, along with a label and error
173+ message (if there is one) input element;
174+
175+ * ``form_end() `` - Renders the end tag of the form and any fields that have not
176+ yet been rendered, in case you rendered each field yourself. This is useful
177+ for rendering hidden fields and taking advantage of the automatic
178+ :ref: `CSRF Protection <forms-csrf >`.
179+
180+ .. seealso ::
181+
182+ As easy as this is, it's not very flexible (yet). Usually, you'll want to
183+ render each form field individually so you can control how the form looks.
184+ You'll learn how to do that in the ":ref: `form-rendering-template `" section.
171185
172186Before moving on, notice how the rendered ``task `` input field has the value
173187of the ``task `` property from the ``$task `` object (i.e. "Write a blog post").
@@ -753,25 +767,20 @@ of code. Of course, you'll usually need much more flexibility when rendering:
753767 <?php echo $view['form']->row($form['dueDate']) ?>
754768 <?php echo $view['form']->end($form) ?>
755769
756- Take a look at each part:
757-
758- * ``form_start(form) `` - Renders the start tag of the form.
770+ You already know the ``form_start() `` and ``form_end() `` functions, but what do
771+ the other functions do?
759772
760773* ``form_errors(form) `` - Renders any errors global to the whole form
761774 (field-specific errors are displayed next to each field);
762775
763776* ``form_row(form.dueDate) `` - Renders the label, any errors, and the HTML
764777 form widget for the given field (e.g. ``dueDate ``) inside, by default, a
765- ``div `` element;
766-
767- * ``form_end() `` - Renders the end tag of the form and any fields that have not
768- yet been rendered. This is useful for rendering hidden fields and taking
769- advantage of the automatic :ref: `CSRF Protection <forms-csrf >`.
778+ ``div `` element.
770779
771780The majority of the work is done by the ``form_row `` helper, which renders
772- the label, errors and HTML form widget of each field inside a ``div `` tag
773- by default. In the :ref: `form-theming ` section, you'll learn how the ``form_row ``
774- output can be customized on many different levels.
781+ the label and HTML form widget of each field inside a ``div `` tag by default.
782+ In the :ref: `form-theming ` section, you'll learn how the ``form_row `` output
783+ can be customized on many different levels.
775784
776785.. tip ::
777786
@@ -958,18 +967,11 @@ to the ``form()`` or the ``form_start()`` helper:
958967 .. code-block :: html+jinja
959968
960969 {# app/Resources/views/Default/new.html.twig #}
961- {{ form(form, {'action': path('target_route'), 'method': 'GET'}) }}
962-
963970 {{ form_start(form, {'action': path('target_route'), 'method': 'GET'}) }}
964971
965972 .. code-block :: html+php
966973
967974 <!-- app/Resources/views/Default/newAction.html.php -->
968- <?php echo $view['form']->form($form, array(
969- 'action' => $view['router']->generate('target_route'),
970- 'method' => 'GET',
971- )) ?>
972-
973975 <?php echo $view['form']->start($form, array(
974976 'action' => $view['router']->generate('target_route'),
975977 'method' => 'GET',
0 commit comments