I have been tearing my hair out for a few days trying to figure out
how i can do my own validation for things more advanced than regex,
and still retain the status that invalidate() creates without it being
reset by save().

Now i suddenly realised i could just extend AppModel like this: -

function save($data = null, $validate = true, $fieldList = array()) {
        $temp = $this->validationErrors;
        parent::save($data, $validate = true, $fieldList = array());
        $this->validationErrors = array_merge($this->validationErrors,
$temp);
}

Now it appears, on first impressions, to work just fine.  I can do
some database checks, then invalidate() a certain field, then when i
call save it may reset the validationErrors array but my extension
backs it up first, then merges it with any validation errors that
save() returns from the cake regex validation.  Because i use my
backed-up validationErrors ($temp) as the second parameter, it will
keep the elements created by my invalidate() calls over anything
created by the cake regex validation.

It almost seems too easy and i'm thinking there may be something
horribly obvious i'm missing!!  Can anyone see any pitfalls with this
simple bit of code?

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 cake-php@googlegroups.com
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