Thursday, February 7, 2008

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
}
else { $this->set( 'data', $this->params['data'] ); $this->validateErrors( $this->User ); $this->render();
}
This code snippet made by Devo.

No comments: