Skip to content

Commit f1708f5

Browse files
committed
Modifying the best practice to use form_start() instead of <form
1 parent 0a21446 commit f1708f5

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

best_practices/forms.rst

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,29 +157,15 @@ There are a lot of ways to render your form, ranging from rendering the entire
157157
thing in one line to rendering each part of each field independently. The
158158
best way depends on how much customization you need.
159159

160-
The simplest way - which is especially useful during development - is to render
161-
the form tags manually and then use ``form_widget()`` to render all of the fields:
160+
One of thhe simplest ways - which is especially useful during development -
161+
is to render the form tags and use ``form_widget()`` to render all of the
162+
fields:
162163

163164
.. code-block:: html+jinja
164165

165-
<form method="POST" {{ form_enctype(form) }}>
166+
{{ form_start(form, {'attr': {'class': 'my-form-class'} }) }}
166167
{{ form_widget(form) }}
167-
</form>
168-
169-
.. best-practice::
170-
171-
Don't use the ``form()`` or ``form_start()`` functions to render the
172-
starting and ending form tags.
173-
174-
Experienced Symfony developers will recognize that we're rendering the ``<form>``
175-
tags manually instead of using the ``form_start()`` or ``form()`` functions.
176-
While those are convenient, they take away from some clarity with little
177-
benefit.
178-
179-
.. tip::
180-
181-
The exception is a delete form because it's really just one button and
182-
so benefits from some of these extra shortcuts.
168+
{{ form_end(form) }}
183169

184170
If you need more control over how your fields are rendered, then you should
185171
remove the ``form_widget(form)`` function and render your fields individually.

0 commit comments

Comments
 (0)