0

这是我的表格:个人资料表格

它有两个元素 password 和 passwordConf

    $this->password= new Zend_Form_Element_Password("password",array("label"=>"Password","required"=>true));
    $this->passwordConf= new Zend_Form_Element_Password("confpassword",array("label"=>"Retype","required"=>true));
    $this->passwordConf->addValidator("Identical",array("token"=>"password"));
    $this->save=new Zend_Form_Element_Submit("save",array("label"=>"Change Password","class"=>"btn btn-primary"));

所以我在控制器中有一个这个实例并将它传递给 POST 数据

    $profileForm= new Application_Form_Profile();

    if($_POST)
    if($profileForm->isValid($_POST))
    {

        $membersTable= new Application_Model_DbTable_Members();
        $member=$membersTable->find($this->user->id)->current();
        $member->password=sha1($profileForm->getValue("password").$member->salt);
        $this->_helper->flashMessenger(array("type"=>"success","content"=>"Password Changed!"));
        $this->_redirect("");

        $member->save();
    }

    $this->view->profileForm=$profileForm;
}

但由于某种原因,我收到 Zend Empty 错误消息。我还注意到没有填充表单字段。我检查了 Chrome 中的响应,看起来帖子数据很好地传递到了页面。甚至做了一个 print_r(POST) ,甚至所有数据看起来都很好。我在上面的代码块之前和之后都这样做了,但是没有用。尽管传递了数据,但它只是不填充表单。

PS:错误信息仅针对密码确认字段。密码字段工作正常

4

1 回答 1

0

The problem here was that the nae of the class variable and the name of the element must match

$this->passwordConf= new Zend_Form_Element_Password("confpassword",array("label"=>"Retype","required"=>true));

i.e $this->passwordConf and confpassword should not be different otherwise this error will happen

于 2013-08-07T03:42:15.907 回答