I am curious about the way in which Sonata Admin handle and displays error messages as I need them to be a little more descriptive. For instance when the message comes from DB because a constraint fails I got a message like this:
An error has occurred during update of item "Media Title Test".
But if I leave a required field empty the error is the same. I want to know if it's possible to handle this in some way in order to be more descriptive. Any advice or help?
You can pass validation rules and message using Constraint in your entity.
// src/AppBundle/Entity/Author.php
// ...
use Symfony\Component\Validator\Constraints as Assert;
class Author
{
/**
* @Assert\Choice(
* choices = { "male", "female", "other" },
* message = "Choose a valid gender."
* )
*/
public $gender;
// ...
}
Validation Constraints Reference will give you a full list of constraint available by default in Symfony.