Wednesday, January 25, 2012

Re: using transactions in cake

Take a look at the saveAll() method in the Model class, it will handle validation and saving and transactions.

As far as ajax feedback, something I've done in the past is pass the ajax response to a function that checks the response for validation errors, then extract those and output them however I want.

$this->Js->submit('Submit', array('success'=>'onSuccess(event, data, textStatus)');

then your js may look something like (assuming jquery)

function onSuccess(event, data, textStatus) {
$(data).find('div.error'); // etc.
}

If you use the form helper, it will create a div.error for each validation error which you can then extract the text from and display however you want.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: