Symfony2 Validator Message depend on group

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

Answers


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

Need Your Help

How do I define a function within a function in Clojure and reference that function?

clojure

I wrote a function to compute the symmetric difference of two sets (one of the problems on the 4clojure site). The function passed the unit tests, but it's not as clean as I would like, given that I

Why tabs content is visible always in materializecss

jquery css html5 materializecss

I was trying to test how can I create tabs using materialize, and I was testing this code

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.