I'm using CakePHP 1.1 and my call from the controller is:

if($this->Model->create() && $this->Model->validates($this->data))

I have also tried:
if($this->Model->create($this->data) && $this->Model->validates())
if($this->Model->validates())

And when I use this in my model:
    function beforeValidate()
        {
            $this->log("model.php: beforeValidate()");
            $this->log($this->data);
            return true;
        }

I get this in my log every time:
2007-04-05 11:35:50 Error: model.php: beforeValidate()
2007-04-05 11:35:50 Error: Array
(
)

I checked, and $this->data is full prior to the call to both create()
and validates(). I have tried the call to validates() w/o $this->data
and the check didn't work for anything. That doesn't make sense to me
because the api shows that validates() calls invalidFields() which
assigns $this-data to a local $data variable before it calls
beforeValidate(). The create() unsets $this->data, yet I still get a
correct result when I use $this->data as an argument to validates().
If I skip the call to create(), I can invalidate the fields I want,
but I have to do it in the controller prior to the call to
validates(), because I'm not getting a $this->data in
beforeValidates(). I don't see what I'm doing wrong. Thanks for the
response. I'm starting to feel a bit lonely out here.

2z

On Apr 5, 4:44 am, "Dia" <[EMAIL PROTECTED]> wrote:
> in your controller :
> ...
> $this->MyModel->set($this->data);
> if ($this->MyModel->validates()) {
> ...
>
> or, if using CakePHP 1.2.x.x :
> if ($this->MyModel->create($this->data) and $this->MyModel-
>
> >validates())
>
> the array shouldn't be empty any more in beforeValidate function


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