It wouldn't require much Cake knowledge as much as basic programming
knowledge to create a custom validation rule. You would liek that
your field is unique, so here is what you could do:
add this to your model:
function uniqueValidation($data, $field){
$list = $this->Model->find('list' array('fields'=>$field));
if(in_array($data['Model'][$field], $list)){
return false;
}else{
return true;
}
}
and this on top...
var $validate = array(
'field' => array(
'rule' => array('uniqueValidation', 'field1'),
'message' => 'The name is already taken, please choose another
one.'
),
'field2' => array(
'rule' => array('uniqueValidation', 'field2'),
'message' => 'The name is already taken, please choose another
one.'
),
);
You could even add the function to your app_model and use it through
your whole application.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---