Hi all.
I've been trying to get the isUnique validation to work in cake 1.2
but I don't seem to be able to get the syntax right. Ultimately I'd
like it to check the uniqueness of two fields together, but I can't
even get it working with one at the moment.
I have the following validation rule in my Model:
var $validate = array(
"name"=>array(
"unique"=>array(
"rule"=>array("isUnique", "name")),
"message"=>"A contact with that name already
exists"
)
)
);
Which generates the following error on submission of the form:
Warning (2): Illegal offset type in isset or empty [CORE\cake\libs
\model\model.php, line 1649]
This is the line that's failing:
if (isset($this->data[$this->name][$field])) {
At this point in the code, $field = the value of the field being
submitted, NOT the name of the field.
I understand that cake 1.2 is still in beta, so my question is:
Is the isUnique functionality incomplete/broken, or is my rule broken?
I've tried a couple of variations on the syntax but still get the same
error.
As a side note, I suspect isUnique might not meant to be referenced in
a rule and is meant to be referenced in the controller. If this is
true can someone point me towards some examples of how / where it
should be used?
I could also use some examples of how to validate uniqueness based on
two or more fields. In the example above I would like to ultimately
check the uniqueness of name and institution_id (both fields in the
same table). (ie. names are only unique for a given institution).
Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---