@Miles J

When I am viewing a project, there is a link to "Add New Risk".  When
the user clicks the link, the ID of the project from which they
clicked "Add New Risk" must be passed to the risk controller.

project_id is a foreign key in the Risks table.

Rather than the user seeing a dropdown and selecting the project, I
want the system to automatically set the project (remember that "Add
New Risk" link is the view of a specific project with a specific ID).

On Jun 3, 12:48 pm, Miles J <mileswjohn...@gmail.com> wrote:
> To pass the variables as an action argument, do it like so:
>
> Router::connect('/risks/add/:project_id', array('controller' =>
> 'risks', 'action' => 'add'), array('project_id' => '[0-9]+', 'pass' =>
> array('project_id')));
>
> <?php echo $html->link('Project', array('controller' => 'risks',
> 'action' => 'add', 'project_id' => $id)); ?>
>
> BUT YOU DONT HAVE TO DO THAT!
> Why are you setting up a route if the controller/action will be the
> same, remove the route and just do:
>
> <?php echo $html->link('Project', array('controller' => 'risks',
> 'action' => 'add', $id)); ?>
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to