Hi all,
I have question about validation
I have a 'email' text input field, I check in my model that this field
isn't empty and it's unique in my db.
It's work but I'd like that when the first rule is not satisfied it
don't try to check the second rule.
Now it check first rule (if blank it set "required"), so it check
second rule and it overwrite my first message and it display
"unique...".
myview:
<?php echo $form->input('email', array('error' => array(
'required' => 'Please specify a valid email',
'unique' => 'Please insert a unique email'
))); ?>
mymodel:
var $validate = array(
'email' => array(
'required' => VALID_NOT_EMPTY,
'unique' => array( 'rule' => 'checkUnique', 'email'))
);
function checkUnique($data, $fieldName) {
$valid = false;
if(isset($fieldName[0]) && $this->hasField($fieldName[0])) {
$valid = $this->isUnique(array($fieldName[0] => $data));
}
return $valid;
}
thanks all!!!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---