Trying to sort this out but not getting anywhere.
I need to respond based on how the request was made.
So first I need to know if the data was saved:
$saved = $this->User->save($this->Controller->request->data, true,
$forceFields);
Then return the saved / error message back to the user.
But then it gets messy and just looks wrong. Has to be a correct was as this
clearly is not it. (ajax response gets sent back as a JSON response)
SNIP FROM COMPONENT IN A PLUGIN (but gives you an idea)
if ($saved && !$this->Controller->request->is('ajax')) {
$this->Session->setFlash(__('Good stuff saved via HTTP
request.'));
} else {
$this->Session->setFlash(__('Nope via HTTP.'));
$this->Controller->redirect(array('action' => 'index'));
}
if ($saved && $this->Controller->request->is('ajax')) {
$response = array(
'status' => true,
'clear' => true,
'message' => 'Good stuff saved via ajax.');
} else {
$response = array(
'clear' => false,,
'message' => 'Nope via ajax.');
}
Thanks,
Dave
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.