[英]Cakephp 1.2 this->set not working
So I am setting a variable to be used in view. 所以我设置了一个在视图中使用的变量。 This happens during a form POST.
这在表单POST期间发生。 Maybe this can give some hints to someone.
也许这可以给某些人一些提示。
public function confirm_card(){
if(!isset ($this->data['UserPayment']) && empty($this->data['UserPayment'])){
$this->Session->setFlash(__d('payments', 'Select payment method', true), 'flash_error');
$this->redirect($this->referer());
}
else{
foreach($this->data['UserPayment'] as $key=>$up){
if(!empty($up)){
$this->set(array('paytype'=>$key));
return;
}
}
}
}
And in view 并在视野中
echo $paytype;
Result in view 结果在视图中
Notice (8): Undefined variable: paytype
The key is returned as it should be so no empty values there. 键返回,因为它应该是没有空值。 This should be very basic... I am missing something here?
这应该是非常基本的...我在这里遗漏了一些东西?
Try with 试试吧
$this->set('paytype', $key);
Change 更改
$this->redirect($this->referer());
The problem was !empty($up)
vs $up != ''
? 问题是
!empty($up)
vs $up != ''
?
$up
is normally 0 or 1 ? $up
通常是0还是1?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.