On Mon, Feb 9, 2009 at 9:33 PM, ohcibi <[email protected]> wrote:

>
> Hi everybody,
>
> i have set up a Contact-Model like this:
> http://paste.pocoo.org/show/103359/
> (according to http://snook.ca/archives/cakephp/contact_form_cakephp/).
> i want to provide international validation messages so i output the
> form-fields like this: http://paste.pocoo.org/show/103365/ .. however
> the error-messages are still some default-ones... does anybody know
> why this could be?
>

Just like Gwoo said, here is an example that might work (untested code):

var $validate = array(
   'name' => array(
      'minlength' => array(
           'rule' => array('minLength', 1)
      )
   ),
   'email' => array(
      'minlength' => array(
           'rule' => array('minLength', 1),
           'last' => true
      ),
      'valid' => array(
           'rule' => 'email'
      )
   ),
   'message' => array(
       'minlength' => array(
           'rule' => array('minLength', 1)
       )
   )
);

.. and your view:

echo $form->input('Contact.name',array(
   'error' => array(
      'minlength' => __('Please enter your name',true)
    )));
echo $form->input('Contact.email',array(
   'error' => array(
      'minlength' => __('Please enter your Email address',true),
      'valid' => __('Please enter a valid Email address',true)
    )));
echo $form->input('Contact.message',array(
   'error' => array(
      'minlength' => __('Please don\'t send blank messages',true)
    )));


Also, I thought it would be worth mentioning that if you don't want to
specify the error messages in the view, you can also set them in your
beforeValidate() function.

- Gonzalo

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

Reply via email to