As far as I know, since CakePHP runs through the validation rules in
sequence, it has a catchall, where validation will fail if *ANY* of the
rules for a specific field fails, and immediately stops trying to validate
that field. What this means, is that only the first failed rule for a field
will display it's message. Now, if anyone knows a way around this, I'd love
to hear about it.

On Sat, Feb 23, 2008 at 4:23 PM, BlenderStyle <[EMAIL PROTECTED]>
wrote:

>
> I'm using CakePHP 1.2.0.6311. I'm having an issue when using multiple
> validation rules per field (thanks to http://book.cakephp.org for the
> help) where only the first failed rule is displayed in the view.
> Example:
>
> CustomModel:
> var $validate = array(
>  'my_field' => array(
>    'minlength' => array(
>      'rule' => array('minLength', 4),
>      'message' => 'Must Be at Least 4 Characters Long'
>    ),
>    'alphanumeric' => array(
>      'rule' => 'alphaNumeric',
>      'message' => 'Must Only Contain Alphanumeric Characters'
>  );
>
> CustomsController:
> function testValidate() {
>  if(!empty($this->data)) {
>    $this->User->set($this->data);
>    $this->User->validates();
>  }
> }
>
> test_validate.ctp:
> echo $form->create('Custom', array('controller' => 'customs', 'action'
> => 'testValidate'));
> echo $form->input('my_field');
> echo $form->create('submit');
>
> If both the minlength and alphanumeric rules fail, only the
> minlength's message is displayed. However, the validation works with
> one or the other.
>
> So, my first question is, am I doing something wrong or is this not a
> feature of CakePHP 1.2.0.6311? Last question is - and this may be
> stupid - but how does the model pass the message to the view?
> >
>


-- 
In the name of Life, Liberty, and the pursuit of my sanity.
Siebren Bakker(Aevum Decessus)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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