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
46
46
47
47
class Author
48
48
{
49
+ const GENRES = ['fiction', 'non-fiction'];
50
+
49
51
/**
50
52
* @Assert\Choice({"New York", "Berlin", "Tokyo"})
51
53
*/
52
54
protected $city;
53
55
54
56
/**
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.")
56
60
*/
57
61
protected $genre;
58
62
}
@@ -210,7 +214,7 @@ constraint.
210
214
}
211
215
}
212
216
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 ``,
214
218
you can pass the class name and the method as an array.
215
219
216
220
.. configuration-block ::
You can’t perform that action at this time.
0 commit comments