diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index aeeadee7a64..b4d5a9a2f40 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -45,6 +45,11 @@ If your valid choice list is simple, you can pass them in directly via the class Author { + /** + * @Assert\Choice({"New York", "Berlin", "Tokyo"}) + */ + protected $city; + /** * @Assert\Choice(choices = {"male", "female"}, message = "Choose a valid gender.") */ @@ -56,6 +61,7 @@ If your valid choice list is simple, you can pass them in directly via the # src/AppBundle/Resources/config/validation.yml AppBundle\Entity\Author: properties: + city: [New York, Berlin, Tokyo] gender: - Choice: choices: [male, female] @@ -70,6 +76,13 @@ If your valid choice list is simple, you can pass them in directly via the xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd"> + + + New York + Berlin + Tokyo + +