Im having trouble using redirect. My $id variable isnt being passed.
I've literally been using cakephp for a week and have read the
redirect documentation a dozen times and cant figure the problem out.
So please be kind. I was using slugs, but removed them to first
understand the problem.
The scenario:
I have a horses controller and and images controller. After a horse is
added it redirects the admin to admin/horses/view/36 (the id of the
horse). In this view page, there is a link to admin/images/add and i
pass the $horse['Horse']['id'] variable, so the url is admin/images/
add/36. Here is my admin_add function from the images controller:
function admin_add($id = null) {
$this->set('id',$id);
if (!empty($this->data)) {
$this->Image->create();
if ($this->Image->save($this->data)) {
$this->Session->setFlash('The image has been saved', true);
$this->redirect(array('controller'=>'horses',
'action'=>'admin_view', $id));
} else {
$this->Session->setFlash(__('The image could not be saved. Please,
try again.', true));
}
}
}
As you can see, im trying to redirect back to the admin view of the
original horse. If i put in the number 36, it works. However, using
$id it only gives me 'invalid id for horse.' My goal is to simply be
able to add several images for each horse. If there is a more
intuitive way for doing this, please let me know.
thanks
--
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:
Post a Comment