Skip to content

Commit

Permalink
Merge branch '3.4' into 4.2
Browse files Browse the repository at this point in the history
* 3.4:
  [Validator] Explained how to use array constant in annotation
  • Loading branch information
javiereguiluz committed Mar 7, 2019
2 parents 32e7bfc + 687d345 commit 50a78d1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ If your valid choice list is simple, you can pass them in directly via the
class Author
{
const GENRES = ['fiction', 'non-fiction'];
/**
* @Assert\Choice({"New York", "Berlin", "Tokyo"})
*/
protected $city;
/**
* @Assert\Choice(choices={"fiction", "non-fiction"}, message="Choose a valid genre.")
* You can also directly provide an array constant to the "choices" option in the annotation
*
* @Assert\Choice(choices=Author::GENRES, message="Choose a valid genre.")
*/
protected $genre;
}
Expand Down Expand Up @@ -203,7 +207,7 @@ constraint.
}
}
If the callback is stored in a different class and is static, for example ``App\Entity\Genre``,
If the callback is defined in a different class and is static, for example ``App\Entity\Genre``,
you can pass the class name and the method as an array.

.. configuration-block::
Expand Down

0 comments on commit 50a78d1

Please sign in to comment.