Is it possible to add a domain string to validation messages in CakePHP models? I have all my messages localized with __d():
echo __d('my_app_name', 'This is a regular message');
But validation messages in a model are plain strings or sprintf arguments:
'my_field' => array(
'my_rule' => array(
'rule' => 'alphanumeric',
'message' => 'Only letters and numbers allowed',
)
)
'another_field' => array(
'another_rule' => array(
'rule' => 'alphanumeric',
'message' => ('Only %s and %s allowed', 'letters', 'numbers'),
)
)
Thanks!!!
Assuming you’re using CakePHP 2.x:
Cake’s
Modelclass has a PropertyvalidationDomain, you might just addpublic $validationDomain = "yourdomain";to your model to get what you want.
Info from API:
See http://api20.cakephp.org/class/model