有一个等待参数的动作,要运行此动作我需要一个参数。但是在这个动作中我对其他形式进行了验证,之后我的第一个变量总是消失。
我如何在isValid之后保留$var
?
public function myAction(){
if ($this->getRequest()->isPost() || $this->getRequest()->getParam('number')){
//this is where got my number
$number = $this->getRequest()->getParam ('number');
//and use to display site.
if ($this->getRequest()->isPost()){
if($commentForm->isValid($this->getRequest()->getPost())){
//if I get Valid data I do upload or etc.
} else {
//but if form is inValid won't display everything one more time.
//but **$number is now Null**.
$this->view->data = $tUser->getCommentAndUserByTelephone($number);
$this->view->commentForm = $commentForm;
}
}
}
}
如何在没有重新发布的情况下保留此$number
答案 0 :(得分:0)
答案 1 :(得分:0)
传递该号码以查看$this->view->number = $number;
并重新发送,而不是新号码。简单!