I have BaseEntity
class:
class BaseEntity
{
/**
* The name.
*
* @var string
*
* @ORM\Column(name="name", type="string", length=255, unique=true, nullable=false)
* @Assert\Length(min=2, max=255, minMessage="default.name.short", maxMessage="default.name.long")
* @Assert\NotBlank(message = "default.name.not_blank")
*/
private $name;
}
and
class UserEntity extends BaseEntity
{
/**
* {@inheritDoc}
*
* @Assert\Length(min=2, max=255, minMessage="user.name.short", maxMessage="default.name.long")
* @Assert\NotBlank(message = "user.name.not_blank")
*/
private $name;
}
Now, When I post a new UserEntity
into the form with long or short name Symfony gives me 2 errors: (for long:)
But I want it to show only ONE error, so : - user.name.long
e.g. I want to override, but do not add another one
I think what you are looking for a validator group. So you can split up you validation rules into groups.
There is a excellent documentation about this feature:
http://symfony.com/doc/current/validation/groups.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With