【发布时间】:2011-07-04 10:09:35
【问题描述】:
一个简单的问题 Zend_Form 验证是否需要 javascript?如果它确实发生了如果关闭 JS 会发生什么,它会回退到例如正常的 PHP 验证吗?
抱歉,我在文档中找不到任何内容。
干杯。
编辑:
这是我的表格:
class Application_Form_Test extends Zend_Form {
public function init() {}
public function testForm() {
$email = $this->createElement('text', 'email');
$email->setLabel('E-Mail Address');
$email->setRequired(true);
$email->addFilter('StripTags');
$email->addErrorMessage('an email address is required');
$email->addValidator('NotEmpty', true);
$email->addValidator('EmailAddress');
$submit = $this->createElement('submit', 'submit', array('label'=>'Submit'));
$this->addElements(
array(
$email, $submit
)
);
return $this;
}
}
这是我的控制器:
class testController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
if(!Zend_Auth::getInstance()->hasIdentity()) {
$this->_redirect('login/index');
}
$this->_acl = new MyAcl(Zend_Auth::getInstance()->getIdentity());
}
public function indexAction() {
$form = new Application_Form_Test();
$form = $form->testForm();
$form->setAction('/dev/public/test/update')->setMethod('post');
$this->view->form = $form;
}
public function updateAction() {
$form = new Application_Form_Test();
if($this->getRequest()->isPost()){
$formData = $this->_request->getPost();
if($form->isValid($_POST)){
die('i seem to be valid....');
}
else{
die(var_dump($_POST));
}
}
}
}
似乎验证失败。有什么想法吗?
【问题讨论】:
标签: javascript zend-framework zend-form zend-validate