Friday, December 25, 2009

Re: Localization for Model validation messages

i dont like the form-way
it is quite redundant - if you add a new rule you might forget
one or two views which would not be helpful

having it all together in the model is in my opinion a cleaner
approach :)


On 25 Dez., 12:32, John Andersen <j.andersen...@gmail.com> wrote:
> Use the form helpers option for the input fields! Look at:http://book.cakephp.org/view/198/options-error
>
> Thus you localize in the view - example:
>
> echo $form->input(
>    'email',
>    array(
>       'label' => __('e-mail address',true),
>       'error' => array('users_email_rule' => __
> ('users_email_rule',true) )
>    )
> ) ;
>
> Observe the 'error' option! Here I use it to convert the validation
> message into the language that the user is viewing the form.
>
> Enjoy,
>    John
>
> On Dec 24, 7:39 pm, si-mon <sijumo...@gmail.com> wrote:
>
> > Hi All,
>
> > Is there a way to use localization for validation messages in the
> > Model $validate array?
>
> > eg: $validate = array ( 'name' => array('rule'=>'notEmpty',
> > 'message'=>'Name is mandatory' ));
>
> > I need the message 'Name is mandatory' in five different languages.
>
> > In other words: How can we use functions like __('message') like
> > functions in model?
>
> > Please help me. Thanks.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: