Skip to content

Commit a8a24f6

Browse files
Deprecate renderForm()
1 parent 4f43ee8 commit a8a24f6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

form/form_customization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ enough to render an entire form, including all its fields and error messages:
2121
.. code-block:: twig
2222
2323
{# form is a variable passed from the controller via either
24-
$this->renderForm('...', ['form' => $form])
24+
$this->render('...', ['form' => $form])
2525
or $this->render('...', ['form' => $form->createView()]) #}
2626
{{ form(form) }}
2727

forms.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +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

284284
In versions prior to Symfony 5.3, controllers used the method
285285
``$this->render('...', ['form' => $form->createView()])`` to render the form.
286-
The ``renderForm()`` method abstracts this logic and it also sets the 422 HTTP
286+
The ``render()`` method abstracts this logic and it also sets the 422 HTTP
287287
status code in the response automatically when the submitted form is not valid.
288288

289+
.. deprecated:: 6.2
290+
291+
The ``renderForm()`` method is deprecated since Symfony 6.2, use ``render()`` instead.
292+
289293
Then, use some :ref:`form helper functions <reference-form-twig-functions>` to
290294
render the form contents:
291295

@@ -404,7 +408,7 @@ written into the form object::
404408
return $this->redirectToRoute('task_success');
405409
}
406410

407-
return $this->renderForm('task/new.html.twig', [
411+
return $this->render('task/new.html.twig', [
408412
'form' => $form,
409413
]);
410414
}

0 commit comments

Comments
 (0)