I have an app setup using CRUD with 7 actions: index, view, create/
save, edit/update, delete. I did this so I can reuse some functions
for an API, and use the security component to require posting to my
save/update actions.
However, since I am posting to a different action than my form is on,
when a validation error occurs I lose validation errors.
When the redirect occurs, presumably '$this->Post->validationErrors'
is reset. Is there a correct way to retain this other than to write
'$this->Post->validationErrors' to a session?
For example:
function edit($id = null) { // GET
if(!$id) {
$this->Session->setFlash('Invalid Post');
$this->redirect(array('action'=>'index'), null, true);
} else {
$this->data = $this->Post->read(null, $id);
$this->set('action', 'update');
}
}
function update($id = null) { // POST
$this->cleanUpFields();
if($this->Post->save($this->data)) {
$this->Session->setFlash('Post Updated!');
} else {
$this->Session->setFlash('The Post could not be saved. Please,
try
again.');
}
$this->redirect(array('action' => 'edit/' . $this->data['Post']
['id']));
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---