1

I am having a common validator like this for adding User and patien detail

# src/Acme/DemoBundle/Resources/config/validator.yml 
Acme\DemoBundle\Entity\contact:
    properties:
        lastName:
            - NotBlank:
                groups: [adduser, addpatient]
                message: Last Name Should not be blank

What i need is to show different validator message for different groups like

for adduser

User Name Should not be blank

And for addpatient

Patient Name Should not be blank

I tried like

Acme\DemoBundle\Entity\contact:
    properties:
        lastName:
            - NotBlank:
                groups: adduser
                message: User Name Should not be blank
                groups: addpatient
                message: Patient Name Should not be blank

and also

Acme\DemoBundle\Entity\contact:
    properties:
        lastName:
            - NotBlank:
                groups: adduser
                message: User Name Should not be blank
        lastName:
            - NotBlank:
                groups: addpatient
                message: Patient Name Should not be blank

1 Answer 1

4

Try:

Acme\DemoBundle\Entity\contact:
    properties:
        lastName:
            - NotBlank:
                groups: adduser
                message: User Name Should not be blank
            - NotBlank:
                groups: addpatient
                message: Patient Name Should not be blank
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.