If you are using 1.2 then its because of validates() call you are issuing
(sending a parameter to validates() is deprecated). Even though, and whether
you are using 1.1 or 1.2, change:

if ( $this->User->validates($this->data) ) {

to:

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

Or better yet change the whole function to:

function register() {
        if ( !empty($this->data) ) {
                if ( $this->User->create() && $this->User->save($this->data)
) {
                        $this->Session->setFlash('Your registration was
successful.');
                        $this->redirect('/');
                        exit;
                } else {
                        $this->Session->setFlash('Please correct marked
errors');
                }
        }
}

Making sure you have Session as an available component in your controller's
$components variable.

Changes here:

1. Using direct call to save() since it will take care of validation for
you.

2. Removed $this->render() since it is redundant.

3. Removed $this->validateErrors() since validation errors for the model
will be copied into the used helpers automatically.

4. Using setFlash() of the Session component, and redirecting to action only
when needed (in this case I'm redirecting user to home page after successful
registration) You can still use $this->flash() though, just a matter of
preference.

-MI

---------------------------------------------------------------------------

Remember, smart coders answer ten questions for every question they ask. 
So be smart, be cool, and share your knowledge. 

BAKE ON!

blog: http://www.MarianoIglesias.com.ar


-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
de [EMAIL PROTECTED]
Enviado el: Lunes, 02 de Julio de 2007 12:08 a.m.
Para: Cake PHP
Asunto: Re: Problem with beforeValidate()

beforeValidate() is being invoked through the normal flow, i.e. I am
not calling it arbitrarily. Here's my Controller code. Thanks.


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