2009年6月22日星期一

Re: [fw-mvc] Validator message templates

Well, cool. Thanks!
We're browsing your website right now, and it seems really interesting.
So far I'll keep you (the list) informed if I face any problem.

Regards,
-- Nicolas


Jeroen Keppens a écrit :
> You can write an application resource for it. That way the code is
> seperated for the bootstrap, but still initiated by it (be sure to add
> resources.resource_name to your app.ini).
>
> 2 examples of application resources I tried:
>
> http://blog.keppens.biz/2009/06/zendapplication-loading-logs.html
> http://blog.keppens.biz/2009/04/zendapplication-multiple-databases.html
>
> Note regarding the tutes: you actually don't need the run() if you
> have resource config in your ini if I'm not mistaken.
>
> Wkr
> Jeroen
>
> On 22 Jun 2009, at 14:43, Nicolas GREVET wrote:
>
>> Well, yes, thanks. That's the way I thought it should be done, but
>> still, it looks strange to me.
>> Isn't there a way to make this more convenient? Stuffing everything
>> in the bootstrap seems a bit clumsy.
>>
>> Regards,
>> -- Nicolas
>>
>>
>> Emanuel a écrit :
>>> I did it this way:
>>> In the Bootstrap file I added the following function:
>>>
>>> protected function _initValidationTranslator() {
>>> $translations = array();
>>> $translations[Zend_Validate_Alnum::NOT_ALNUM] = '%value%
>>> trebuie sa fie format doar din litere si cifre';
>>> $translator = new Zend_Translate('array', $translations);
>>> Zend_Validate_Abstract::setDefaultTranslator($translator);
>>> }
>>>
>>> I hope this helps.
>>>
>>> On Fri, Jun 19, 2009 at 15:27, Nicolas GREVET <ngrevet@alteo.fr
>>> <mailto:ngrevet@alteo.fr>> wrote:
>>>
>>> You're not alone at all.
>>> I'd find it particularily useful too, since I don't understand how
>>> we're supposed to override these messages the zend way.
>>>
>>> Regards,
>>> -- Nicolas
>>>
>>>
>>> Neil Garb a écrit :
>>>
>>> Hi ZF-MVC
>>>
>>> Would anyone else find it useful to be able to change
>>> validator messages in a static context?
>>>
>>> Use case:
>>> I don't like 'Value is empty, but non-empty value is required'
>>> in Zend_Validate_NotEmpty
>>> I specify in my controller's init() function:
>>> Zend_Validate_NotEmpty::setMessageTemplate('Please fill in
>>> this field', 'isEmpty');
>>>
>>> This is most valuable for the notempty and inarray validators,
>>> which get instantiated automatically by the form validation
>>> routines.
>>>
>>> - Neil
>>>
>>>
>>>
>>
>
>
>
>

没有评论: