I am new to cake and have been working with it for over a month. I'm
trying to do form field validation and I keep running into
difficulties. I have one form that has fields that are not required
for submission, but some of the un-required fields are dependent on
other un-required fields. Because the fields are not required, I
didn't put them in the validate array in the model. I tried to use
beforeValidate in the model:

function beforeValidate() {
    if( (isset($this->data[$this->name]['field1']) && !isset($this-
>data[$this->name]['field2'])
        $this->invalidate('field2');
}

First off, I get an error stating that $this->data[$this->name] is a
bad index. I put a check in the function to log the contents of $this-
>data and it's empty? I have error messages setup in the view, but I
believe that since these fields aren't in the validate array, the call
to invalidate wouldn't work anyway. Any suggestions on how I might
approach this problem?

Everywhere I see beforeValidate examples, it's using $this->data. Any
ideas on why I don't have any data there?

I'll keep studying the code and the postings. A suggestion to use
http://bakery.cakephp.org/articles/view/55 looks promising, but I'd
really like to understand what's going on when the call to
beforeValidate happens.

Thanks.

2z


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to