-- Dividy <[EMAIL PROTECTED]> wrote
(on Tuesday, 05 February 2008, 08:38 AM -0800):
> Matthew Weier O'Phinney-3 wrote:
> > Yes -- by passing a messages option to the validator when creating the
> > element and/or validator.
> > 
> >     $element->addValidator(
> >         'NotEmpty', 
> >         false, 
> >         array('messages' => array('isEmpty' => 'Alternate message'))
> >     );
> > 
> > You can also pull out the validator object and set the messages you
> > want.
> > 
> >     $element->getValidator('NotEmpty')->setMessage('isEmpty', 'Alternate
> > message');
> > 
> 
> Yes, that's why i asked... ok...
> 
> > So, there are a variety of ways to do this. However, if you use a
> > translator object, then the translations will always be used, so the
> > same translation will be used in all instances of a particular validator.
> > 
> 
> How about having the fieldname prefixing the messageid in the language csv's
> ?
> 
> Some sort of "username.isEmpty;The string username cannot be empty" ?

I see one big issue with this: common translations. If several of the
fields *can* use the same translation, you now have to create duplicate
translations -- or there will be a bunch of extra logic necessary in the
internals to allow for fallbacks, which likely won't perform too well
for the most common use case.

That said, it wouldn't be difficult to subclass Zend_Form_Element to do
this. ;-)

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to