Zend表单验证问题。 [英] Problem with Zend Form validate.
本文介绍了Zend表单验证问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题 - 没有工作形式isValid()方法。
对于开始启动帐户控制器,操作新,点击提交 '并且加载动作成功,
并且它不起作用,所有代码如下。
但是如果我把所有在一个动作和形式动作=相同的动作,所有工作,如何使用两个动作产生相同的结果。对不起英文抱歉。
Problem - don''t work form isValid() method.
For begin start Account controller with action ''new'', Click ''Submit'' and load action success,
and it''s don''t work, all code below.
But if I put all in one action and form action = same action, ALL WORKS, How can I make the same result using two actions. Sorry for bad Eng.
<?php
class AccountController extends Zend_Controller_Action
{
public $newAccountForm;
public function init()
{
$this->newAccountForm = new Application_Form_NewAccount();
}
public function indexAction()
{
}
public function successAction()
{
if ($this->getRequest()->isPost()) {
if ($this->newAccountForm->isValid($this->getRequest()->getPost())) {
//$email = $this->_request->getParam('email');
//$username = $this->_request->getParam('username');
//$password = $this->_request->getParam('password');
//$saveAccount = new Application_Model_SaveAccount();
//$saveAccount->saveAccount($username, $password, $email);
} else {
// Show form with validation errors
$this->view->newAccountForm = $this->newAccountForm;
}
}
}
public function newAction()
{
$this->view->newAccountForm = $this->newAccountForm;
}
}
推荐答案
newAccountForm ;
公共函数init()
{
newAccountForm; public function init() {
this-> newAccountForm = new Application_Form_NewAccount();
}
公共函数indexAction()
{
}
公共函数successAction()
{
if (
this->newAccountForm = new Application_Form_NewAccount(); } public function indexAction() { } public function successAction() { if (
this-> getRequest() - > isPost()){
if (
this->getRequest()->isPost()) { if (
这篇关于Zend表单验证问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文