We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f3fb435 + 35ae166 commit b88e4d7Copy full SHA for b88e4d7
reference/constraints/UniqueEntity.rst
@@ -103,6 +103,29 @@ between all of the rows in your user table:
103
}
104
105
106
+ // src/Form/Type/UserType.php
107
+ namespace App\Form\Type;
108
+
109
+ // ...
110
+ // DON'T forget the following use statement!!!
111
+ use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
112
113
+ class UserType extends AbstractType
114
+ {
115
116
117
+ public function configureOptions(OptionsResolver $resolver): void
118
119
+ $resolver->setDefaults([
120
121
+ 'data_class' => User::class,
122
+ 'constraints' => [
123
+ new UniqueEntity(fields: ['email']),
124
+ ],
125
+ ]);
126
+ }
127
128
129
.. caution::
130
131
This constraint doesn't provide any protection against `race conditions`_.
0 commit comments