Reputation: 7800
I want to override only one message in symfony2 default validation message which is :
This value should be the user current password.
this message has as a key security.validator.user_password
I tried to override this message by creating BundleName/Resources/config/security.yml
.
BundleName/Resources/config/security.yml
security:
validator:
user_password: custom message
I tried xml file and cleared the cache but I get nothing.
Any suggestions ?
Upvotes: 0
Views: 421
Reputation: 472
I found a solution to this when using FOSUserBundle as a parent to my Users bundle:
# Acme\UsersBundle\config\validation.yml
Acme\UsersBundle\Entity\User:
properties:
password:
- Symfony\Component\Security\Core\Validator\Constraints\UserPassword:
message: Please check your current password and try again
This pattern can be used to override any of the default strings which are shown when validation on a given field in that entity fails.
So to clarify:
Hope this helps!
Upvotes: 0
Reputation: 11
I think you can override using the validation.yml file in your bundle config like said on symfony2 doc.
### src/UserBundle/Resources/config/validation.yml
Acme\UserBundle\Form\Model\ChangePassword:
properties:
oldPassword:
- Symfony\Component\Security\Core\Validator\Constraints\UserPassword:
message: "Wrong value for your current password"
Upvotes: 1