symfony - How to pass parameter to translated validation error message -


in symfony2, you can translate validation error messages:

validation file

# src/acme/blogbundle/resources/config/validation.yml acme\blogbundle\entity\author:     properties:         name:             - notblank: { message: "author.name.not_blank" } 

translation file

# validators.en.yml author.name.not_blank: please enter author name. 

but how can pass parameter translation file, if e.g. want pass required min or max length?

author.name.min_length: "required length: %limit% characters." 

what about,

acme\blogbundle\entity\author:     properties:         name:             - notblank: { message: "author.name.not_blank" }             - length:                 min: 3                 minmessage: "author.name.min_length" 

while translation file should contain,

# validators.en.yml author.name.not_blank: please enter author name. author.name.min_length: "required length: {{ limit }} characters." 

the {{ limit }} placeholder here fit min pamarater of length constraint.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -