From fc1954cd9deb985aa34a8723ba3e34381ff05901 Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Thu, 13 Dec 2018 17:23:19 +0100 Subject: [PATCH 1/2] Complete code example for "Adding validation" part --- form/without_class.rst | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/form/without_class.rst b/form/without_class.rst index 29c8fdbfe2c..2f73124c044 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -82,19 +82,22 @@ but here's a short example:: use Symfony\Component\Validator\Constraints\Length; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Form\Extension\Core\Type\TextType; + use Symfony\Component\Form\FormBuilderInterface; - $builder - ->add('firstName', TextType::class, array( - 'constraints' => new Length(array('min' => 3)), - )) - ->add('lastName', TextType::class, array( - 'constraints' => array( - new NotBlank(), - new Length(array('min' => 3)), - ), - )) - ; - + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('firstName', TextType::class, array( + 'constraints' => new Length(array('min' => 3)), + )) + ->add('lastName', TextType::class, array( + 'constraints' => array( + new NotBlank(), + new Length(array('min' => 3)), + ), + )) + ; + } .. tip:: If you are using validation groups, you need to either reference the From 6a9afb8e5460b8b4596cd28c670f3def93b2200f Mon Sep 17 00:00:00 2001 From: Mathieu Santostefano Date: Fri, 14 Dec 2018 09:43:30 +0100 Subject: [PATCH 2/2] Update without_class.rst --- form/without_class.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/form/without_class.rst b/form/without_class.rst index 2f73124c044..e0a6959582e 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -98,6 +98,7 @@ but here's a short example:: )) ; } + .. tip:: If you are using validation groups, you need to either reference the