File tree 1 file changed +6
-2
lines changed 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,17 @@ If your valid choice list is simple, you can pass them in directly via the
43
43
44
44
class Author
45
45
{
46
+ const GENRES = ['fiction', 'non-fiction'];
47
+
46
48
/**
47
49
* @Assert\Choice({"New York", "Berlin", "Tokyo"})
48
50
*/
49
51
protected $city;
50
52
51
53
/**
52
- * @Assert\Choice(choices={"fiction", "non-fiction"}, message="Choose a valid genre.")
54
+ * You can also directly provide an array constant to the "choices" option in the annotation
55
+ *
56
+ * @Assert\Choice(choices=Author::GENRES, message="Choose a valid genre.")
53
57
*/
54
58
protected $genre;
55
59
}
@@ -203,7 +207,7 @@ constraint.
203
207
}
204
208
}
205
209
206
- If the callback is stored in a different class and is static, for example ``App\Entity\Genre ``,
210
+ If the callback is defined in a different class and is static, for example ``App\Entity\Genre ``,
207
211
you can pass the class name and the method as an array.
208
212
209
213
.. configuration-block ::
You can’t perform that action at this time.
0 commit comments