File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 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
4343
4444 class Author
4545 {
46+ const GENRES = ['fiction', 'non-fiction'];
47+
4648 /**
4749 * @Assert\Choice({"New York", "Berlin", "Tokyo"})
4850 */
4951 protected $city;
5052
5153 /**
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.")
5357 */
5458 protected $genre;
5559 }
@@ -203,7 +207,7 @@ constraint.
203207 }
204208 }
205209
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 ``,
207211you can pass the class name and the method as an array.
208212
209213.. configuration-block ::
You can’t perform that action at this time.
0 commit comments