cakephp:从控制器传递变量到视图时的未定义变量错误

时间:2011-09-21 06:56:00

标签: cakephp variables view controller

当我在注册页面点击提交时,我收到"Notice (8): Undefined variable: id [APP\views\merry_parents\report_card.ctp".

我只是想使用$this->data['MerryParent']['id']

merry_parents_controller$this->set($id,$this->data['MerryParent']['id']);传递到report_card视图

有人可以告诉我我做错了什么吗?提前谢谢。

以下是我的代码:

//report_card.ctp

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

1 个答案:

答案 0 :(得分:3)

使用:

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

第一个参数是所需的名称​​为字符串,而不是变量。

相关问题