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.
2 Comments:
awesome tip. I have just started using cakePHP and I was completely lost on how to do this.
This comment has been removed by the author.
Post a Comment
Subscribe to Post Comments [Atom]
<< Home