Cakephp 1.2此->;设置不起作用
因此,我设置了一个变量以在视图中使用。 这发生在表单发布期间。也许这可以给某人一些提示Cakephp 1.2此->;设置不起作用,cakephp,cakephp-1.2,Cakephp,Cakephp 1.2,因此,我设置了一个变量以在视图中使用。 这发生在表单发布期间。也许这可以给某人一些提示 public function confirm_card(){ if(!isset ($this->data['UserPayment']) && empty($this->data['UserPayment'])){ $this->Session->setFlash(__d('payments', 'Select
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;
}
}
}
}
以及
echo $paytype;
结果在望
Notice (8): Undefined variable: paytype
该键按原样返回,因此不存在空值。
这应该是非常基本的。。。我这里遗漏了什么?试试看
$this->set('paytype', $key);
改变
$this->redirect($this->referer());
问题是!空($up)
vs$up!=''代码>
$up
通常是0或1?可能是$this->set('paytype',$key);我已经这么做了,但它不起作用为什么要使用$this->redirect($this->render())代码>?也许你想做$this->redirect($this->referer())代码>?你只是在else
.da,corect:)中设置paytype
,哈哈,但无论如何,这不是问题所在。这是奇怪的,因为它应该只是工作…啊,还有一件事,也许这是重要的。这是在调试后扫描后发生的$this->data['UserPayment']
?您只需将变量设置为$up
不为空。也许你没有这些价值观。