Hi Stu,
After your light I think that figure out the question.
In the example below, name and country are the couple fields I was
talked. The model is Author.
here's the code (With more time, should it be optimied?) within the
model author.php
var $validate = array(
'name' => array(
'rule' => array('uniqueValidation', 'name','country'),
'message' => 'The author name and country is already taken,
please choose another.'
),
'country' => array(
'rule' => array('uniqueValidation', 'name','country'),
'message' => 'The author name and country is already taken,
please choose another.'
),
);
function uniqueValidation($data, $field1, $field2){
$lists1 = $this->find('list', array('fields'=>$field1));
$lists2 = $this->find('list', array('fields'=>$field2));
//if(in_array($this->data['Author'][$field1], $lists) && in_array
($this->data['Author'][$field2], $lists)) {
if(in_array($this->data['Author'][$field1], $lists1) && in_array
($this->data['Author'][$field2], $lists2)) {
return false;
} else {
return true;
}
}
Thanks a lot.
Alexandre
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---