vaanipala
vaanipala

Reputation: 1291

cakephp: undefined variable error when passing variable from controller to view

When I click submit in signup page, I'm getting "Notice (8): Undefined variable: id [APP\views\merry_parents\report_card.ctp".

I'm just trying to pass $this->data['MerryParent']['id'] from merry_parents_controller to the report_card view using $this->set($id,$this->data['MerryParent']['id']);

Can someone tell me on what i'm doing wrong? thanks in advance.

following is my code:

//report_card.ctp

 <?php
     echo 'HALLO';
     echo $id;
 ?>

Upvotes: 1

Views: 1836

Answers (1)

deceze
deceze

Reputation: 521995

Use:

$this->set('id', $this->data['MerryParent']['id']);

The first argument is the desired name as a string, not as a variable.

Upvotes: 3

Related Questions