From f02713012be1f0468cf7167e98f27b28ef38d005 Mon Sep 17 00:00:00 2001 From: Issam KHADIRI Date: Fri, 20 Dec 2024 00:01:41 +0100 Subject: [PATCH 1/2] Update without_class.rst --- form/without_class.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/form/without_class.rst b/form/without_class.rst index 436976bdfcc..860eb452da1 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -99,7 +99,8 @@ but here's a short example:: 'constraints' => new Length(['min' => 3]), ]) ->add('lastName', TextType::class, [ - 'constraints' => [ +// the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` + 'constraints' => [ new NotBlank(), new Length(['min' => 3]), ], @@ -166,6 +167,9 @@ This can be done by setting the ``constraints`` option in the This means you can also do this when using the ``createFormBuilder()`` method in your controller:: +// the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` + + $form = $this->createFormBuilder($defaultData, [ 'constraints' => [ 'firstName' => new Length(['min' => 3]), From c0743c01f841aba09b200adbc2eca1e48e5b5700 Mon Sep 17 00:00:00 2001 From: Issam KHADIRI Date: Fri, 20 Dec 2024 00:19:00 +0100 Subject: [PATCH 2/2] Update without_class.rst --- form/without_class.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/form/without_class.rst b/form/without_class.rst index 860eb452da1..c3e1f7c7cc2 100644 --- a/form/without_class.rst +++ b/form/without_class.rst @@ -99,7 +99,7 @@ but here's a short example:: 'constraints' => new Length(['min' => 3]), ]) ->add('lastName', TextType::class, [ -// the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` +.. the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` .. 'constraints' => [ new NotBlank(), new Length(['min' => 3]), @@ -167,7 +167,7 @@ This can be done by setting the ``constraints`` option in the This means you can also do this when using the ``createFormBuilder()`` method in your controller:: -// the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` +.. the following configuration triggers an error `An error has occurred resolving the options of the form "Symfony\Component\Form\Extension\Core\Type\FormType": The option "constraints" with value array is expected to be of type "Symfony\Component\Validator\Constraint" or "Symfony\Component\Validator\Constraint[]", but one of the elements is of type "array".` .. $form = $this->createFormBuilder($defaultData, [