From 72db52c70ce0eadc7f67031d41dad273cf012258 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 7 Dec 2015 14:13:51 +0100 Subject: [PATCH 1/2] Remove isSubmitted call Streamline with http://symfony.com/doc/current/book/forms.html#handling-form-submissions There is no need for `isSubmitted` as this is done inside `isValid` --- cookbook/doctrine/registration_form.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index a03ce641ba0..07626a1960e 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -220,7 +220,7 @@ controller for displaying the registration form:: // 2) handle the submit (will only happen on POST) $form->handleRequest($request); - if ($form->isValid() && $form->isSubmitted()) { + if ($form->isValid()) { // 3) Encode the password (you could also do this via Doctrine listener) $password = $this->get('security.password_encoder') ->encodePassword($user, $user->getPlainPassword()); From d3542ed2033d4b2b6c3345e6de9727ffe5f0bbb7 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 7 Dec 2015 15:50:24 +0100 Subject: [PATCH 2/2] Update order of calls To follow best practice swap order of calls. --- cookbook/doctrine/registration_form.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index 07626a1960e..c0aaa41635c 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -220,7 +220,7 @@ controller for displaying the registration form:: // 2) handle the submit (will only happen on POST) $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { // 3) Encode the password (you could also do this via Doctrine listener) $password = $this->get('security.password_encoder') ->encodePassword($user, $user->getPlainPassword());