File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ This can be done by setting the ``constraints`` option in the
137137 use Symfony\Component\Form\Extension\Core\Type\TextType;
138138 use Symfony\Component\Form\FormBuilderInterface;
139139 use Symfony\Component\OptionsResolver\OptionsResolver;
140+ use Symfony\Component\Validator\Constraints\Collection;
140141 use Symfony\Component\Validator\Constraints\Length;
141142 use Symfony\Component\Validator\Constraints\NotBlank;
142143
@@ -149,17 +150,15 @@ This can be done by setting the ``constraints`` option in the
149150
150151 public function configureOptions(OptionsResolver $resolver): void
151152 {
152- $constraints = [
153- 'firstName' => new Length(['min' => 3]),
154- 'lastName' => [
155- new NotBlank(),
156- new Length(['min' => 3]),
157- ],
158- ];
159-
160153 $resolver->setDefaults([
161154 'data_class' => null,
162- 'constraints' => $constraints,
155+ 'constraints' => new Collection([
156+ 'firstName' => new Length(['min' => 3]),
157+ 'lastName' => [
158+ new NotBlank(),
159+ new Length(['min' => 3]),
160+ ],
161+ ]),
163162 ]);
164163 }
165164
You can’t perform that action at this time.
0 commit comments