views:

9

answers:

1

Is there a simple way to modify/customize error messages generated by Symfony validators?

eg. When using a string validator, if the field is empty, then the message "Required" is displayed by default with the field.

This surely comes from its class, but is there a way to change the message for the String Validator globally so that it applies to all instances?

Thanks in advance.

PS: wouldn't appreciate a solution that requires changes to the Symfony base code

A: 

Hi Prasad,

I yet don't know if you can manipulate the default error messages globally, but you can access the i18n Object where you want with these lines of code:

$i18n = sfContext::getInstance()->getI18N();
$i18n->__('your message');

Maybe it helps you.

Hi, this Q is about modifying error messages generated by form validators. thanks
Prasad