0
如何檢查的形式進行驗證或沒有,我怎麼如果窗體沒有根據驗證如何檢查表單驗證在控制器中的Zend Framework 1.12
在ZF2我們顯示錯誤消息寫爲
userController
$request = $this->getRequest();
$form = new Form_LoginForm();
if($request->isPost()){
if($form->isvalid($this->_request->getPost())){
$authAdapter = $this->getAuthAdapter();
$username = 'john';
$password = '123';
$authAdapter->setIdentity($email)
->setCredential($password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($authAdapter);
if($result->isvalid()){
$identity = $authAdapter->getResultRowObject();
$authStorage = $auth->getStorage();
$authStorage->write($identity);
$this->_helper->redirector(register/user);
echo 'valid';
} else {
$this->view->errorMessage = "User name or password is incorrect";
}
}
}
上面的代碼是在Zend中framework2,我需要的代碼在Zend framework 1.12
。如何獲取的形式從login.phtml
到UserController中,以及如何編寫代碼來檢查確認爲這是寫在Zend的framework2線4
我login.phtml
形式是
<form action="<?php echo $this->url(array('controller'=>'user','action'=>'login'),
'default',true);?>" method="post">
Email: <input type="text" name="user_email" type="email" oninvalid="setCustomValidity('Plz enter valid email ')" onchange="try{setCustomValidity('')}catch(e){}" required />
Password: <input type="password" name="password" required />
<input type="submit" name="submit" value="SUBMIT" />
</form>
你可以看到[示例](http://framework.zend.com/manual/1.12/en/learning.multiuser.authentication.html)的ZF1.12的文檔 – doydoy44
的中其他[示例](http://satish-zendframe.blogspot.fr/20 11/01/creation-login-form-using-zend.html) – doydoy44
thanq,這是非常有幫助的@ doddod44 – Rajitha