$options = array(
'/things/view/%id' => 'View this thing',
'/things/index' => 'Go back to the index'
);
echo $form->input('WhatToDo.next', array('options' => $options,
'label' => 'What do you want to do next?'));
Controller:
// ...
if ($this->Thing->save($this->data)) {
$this->Session->setFlash("Your thing has been saved");
// Grab the submitted URL or default
$url = empty($this->data['WhatToDo']['next']) ? '/' : $this-
>data['WhatToDo']['next'];
// Handle any parameters here
$url = str_replace('%id%', $this->Thing->id, $url);
// Go there
$this->redirect($url);
}
// ...
Might be worth putting this sort of logic in a component if you use it
a lot... Also make sure you validate the submitted url
There are more secure ways of doing this, of course...
hth
grigri
On Oct 3, 3:00 pm, MDB <mdbev...@gmail.com> wrote:
> Hello all, how do I get the selected value from a select drop down
> box. Basically I want to redirect based on the returned value however
> I can not figure out how to get the selected value?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment