@@ -275,16 +275,21 @@ Now that the form has been created, the next step is to render it::
275275
276276 $form = $this->createForm(TaskType::class, $task);
277277
278- return $this->renderForm ('task/new.html.twig', [
278+ return $this->render ('task/new.html.twig', [
279279 'form' => $form,
280280 ]);
281281 }
282282 }
283283
284- In versions prior to Symfony 5.3, controllers used the method
285- ``$this->render('...', ['form' => $form->createView()]) `` to render the form.
286- The ``renderForm() `` method abstracts this logic and it also sets the 422 HTTP
287- status code in the response automatically when the submitted form is not valid.
284+ Internally, the ``render() `` method calls ``$form->createView() `` to
285+ transform the form into a *form view * instance.
286+
287+ ..deprecated ::6.2
288+
289+ Prior to Symfony 6.2, you had to use ``$this->render(..., ['form' => $form->createView()]) ``
290+ or the ``renderForm() `` method to render to form. The ``renderForm() ``
291+ method is deprecated in favor of directly passing the ``FormInterface ``
292+ instance to ``render() ``.
288293
289294Then, use some:ref: `form helper functions <reference-form-twig-functions >` to
290295render the form contents:
@@ -404,7 +409,7 @@ written into the form object::
404409 return $this->redirectToRoute('task_success');
405410 }
406411
407- return $this->renderForm ('task/new.html.twig', [
412+ return $this->render ('task/new.html.twig', [
408413 'form' => $form,
409414 ]);
410415 }
@@ -422,7 +427,12 @@ possible paths:
422427 ``task `` and ``dueDate `` properties of the ``$task `` object. Then this object
423428 is validated (validation is explained in the next section). If it is invalid,
424429:method: `Symfony\\ Component\\ Form\\ FormInterface::isValid ` returns
425- ``false `` and the form is rendered again, but now with validation errors;
430+ ``false `` and the form is rendered again, but now with validation errors.
431+
432+ By passing ``$form `` to the ``render() `` method (instead of
433+ ``$form->createView() ``), the response code is automatically set to
434+ `HTTP 422 Unprocessable Content `_. This ensures compatibility with tools
435+ relying on the HTTP specification, like `Symfony UX Turbo `_;
426436
427437#. When the user submits the form with valid data, the submitted data is again
428438 written into the form, but this time:method: `Symfony\\ Component\\ Form\\ FormInterface::isValid `
@@ -1070,3 +1080,5 @@ Misc.:
10701080
10711081.. _`Symfony Forms screencast series` :https://symfonycasts.com/screencast/symfony-forms
10721082.. _`MakerBundle` :https://symfony.com/doc/current/bundles/SymfonyMakerBundle/index.html
1083+ .. _`HTTP 422 Unprocessable Content` :https://www.rfc-editor.org/rfc/rfc9110.html#name-422-unprocessable-content
1084+ .. _`Symfony UX Turbo` :https://ux.symfony.com/turbo