Wednesday, September 13, 2006

How To Validate data Without Saving?

You know, CakePHP check data only when you saving:

$this -> User -> save ($this->data)

But if you do not needing to save data?

In this case, you can use this "hint":

if ( $this -> User -> validates ( $this -> data ) )
        // OK, good to go


        $this->set( 'data', $this->params['data'] );
        $this->validateErrors( $this->User );


This code snippet made by Devo.


Blogger Kyle Decot said...

awesome tip. I have just started using cakePHP and I was completely lost on how to do this.

12:53 AM  
Blogger Costis Panagiotopoulos said...

This comment has been removed by the author.

6:56 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home