In “ProjectConfiguration” I can customize the output errors, such
sfValidatorBase::setDefaultMessage('min_length', 'Min% min_length% sign');
sfValidatorBase::setDefaultMessage('required', 'Label required');
But for the field “required”, I can not substitute the dynamic field name, like this:
sfValidatorBase::setDefaultMessage('required', 'Label %label% required');
How can I fix it?
You can’t. Or you will have to hack into the global
sfValidatorBase.If you take the example of
min_lengtherror, it is throwing like this (insfValidatorString):As you can see, it takes parameters for
valueandmin_lengthsince the message is defined like this :So it will automatically replace each variable with
%....%.For
requirederror, it’s throwing from thesfValidatorBase(the one which is extended by all validator):As you can see, nothing is given as third parameter, so you can’t configure extra parameter. If you want to do so, you should change:
But this change will be inside the Symfony repository. And this
sfValidatorBaseis extended on every validator, I don’t know how you can apply this modification. At least, you know where do make changes.