Hi,

If I understand you properly, the url 
http://localhost/PBSRG/cake_1_2/risks/add/1
does not correctly pass $project_id into the controllereven though it
appears in the url.
Try <li><?php echo $html->link(__('Add New Risk', true), array
('controller'=> 'risks', 'action'=>'add', $project
['Project']['id'])); ?> </li>
i.e.
without the 'project_id' =>
Also use pr($project_id); in your controller to check the value is
there. Hope that helps.

On Jun 3, 6:15 pm, jake1729 <[email protected]> wrote:
> I have been struggling with this for about 3 weeks.  A variable is not
> being created in the pass array.  I need the value of "project_id" to
> be included when creating a new risk.  The Risks table must have a
> value for project_id.
>
> Please, what am I doing wrong here?
>
> ======
> CONTROLLER (RisksController)
>
>         function add($project_id = null) {
>           if (!empty($this->data)) {
>                         $this->Risk->create();
>                         $this->data['Risk']['project_id'] = $project_id;
>             if ($this->Risk->save($this->data)) {
>                                 $this->Session->setFlash(__('The Risk has 
> been saved', true));
>                                 $this->redirect(array('action'=>'index'));
>                         } else {
>                                 debug($this->params);
>                 $this->Session->setFlash(__('The Risk could not be
> saved. Please, try again.', true));
>                         }
>                 }
>                 $projects = $this->Risk->Project->find('list');
>                 $riskcategories = $this->Risk->Riskcategory->find('list');
>                 $this->set(compact('projects', 'riskcategories'));
>         }
>
> ======
> ROUTE (routes.php)
>
> Router::connect(
>          '/risks/add/:project_id',
>          array(
>                  'controller' => 'risks',
>                  'action' => 'add'
>          ),
>          array(
>                  'pass' => array('project_id')
>          )
>  )
>
> ======
> VIEW (creates link with project_id value; inside of projects view.ctp)
>
> <li><?php echo $html->link(__('Add New Risk', true), array
> ('controller'=> 'risks', 'action'=>'add', 'project_id' => $project
> ['Project']['id'])); ?> </li>
>
> ======
> URL (being passed to risks add action.  The "1" below is the passed
> project_id, whichI need to pass to the database when adding new risk)
>
> http://localhost/PBSRG/cake_1_2/risks/add/1
>
> ======
> DEBUG (debug($this->params);  in the add action in risks_controller)
>
> Array
> (
>     [pass] => Array
>         (
>         )
>     ...
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to