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 @@ -46,13 +46,17 @@ If your valid choice list is simple, you can pass them in directly via the
4646
4747 class Author
4848 {
49+ const GENRES = ['fiction', 'non-fiction'];
50+
4951 /**
5052 * @Assert\Choice({"New York", "Berlin", "Tokyo"})
5153 */
5254 protected $city;
5355
5456 /**
55- * @Assert\Choice(choices={"fiction", "non-fiction"}, message="Choose a valid genre.")
57+ * You can also directly provide an array constant to the "choices" option in the annotation
58+ *
59+ * @Assert\Choice(choices=Author::GENRES, message="Choose a valid genre.")
5660 */
5761 protected $genre;
5862 }
@@ -210,7 +214,7 @@ constraint.
210214 }
211215 }
212216
213- If the callback is stored in a different class and is static, for example ``AppBundle\Entity\Genre ``,
217+ If the callback is defined in a different class and is static, for example ``AppBundle\Entity\Genre ``,
214218you can pass the class name and the method as an array.
215219
216220.. configuration-block ::
You can’t perform that action at this time.
0 commit comments