From 66dd32507e2bda1323e28b419263312f233eafda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 16 Oct 2017 16:24:37 +0200 Subject: [PATCH] [FrameworkBundle] Added doc for ControllerTrait::isFormValid --- best_practices/forms.rst | 17 +++++++++++++++++ forms.rst | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/best_practices/forms.rst b/best_practices/forms.rst index 31ffa4d5707..0c61541af84 100644 --- a/best_practices/forms.rst +++ b/best_practices/forms.rst @@ -218,4 +218,21 @@ handling the form submit. For example, you *could* have a ``new()`` action that submit. Both those actions will be almost identical. So it's much simpler to let ``new()`` handle everything. +.. versionadded:: 4.3 + + The ``AbstractController::isFormValid()`` method was added in Symfony 4.3. + +It's also possible to use a short-cut if your controller extends ``AbstractController``:: + + public function new(Request $request) + { + // build the form ... + + if ($this->isFormValid($form, $request)) { + // process the form data + } + + // render the template + } + Next: :doc:`/best_practices/i18n` diff --git a/forms.rst b/forms.rst index bf0d787782d..822d5675020 100644 --- a/forms.rst +++ b/forms.rst @@ -264,6 +264,25 @@ your controller:: is called. Otherwise, changes done in the ``*_SUBMIT`` events aren't applied to the view (like validation errors). + +.. versionadded:: 4.3 + + The ``AbstractController::isFormValid()`` method was added in Symfony 4.3. + +It's also possible to use a short-cut if your controller extends ``AbstractController``:: + + public function new(Request $request) + { + // build the form ... + + if ($this->isFormValid($form, $request)) { + // process the form data + } + + // render the template + } + + This controller follows a common pattern for handling forms and has three possible paths: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy