zend 验证器不工作
我正在创建一个 Zend 表单。
当我提交表单时,不会显示错误消息。似乎验证器从未被触发。这是我的代码:
$form = new Zend_Form;
$form->setMethod('POST') ->setAttrib('名称','pwdfrm') ->setAttrib('Id','pwdfrm'); $email = new Zend_Form_Element_Text('email'); $email->setLabel('电子邮件:') ->setDecorators($this->文本框) ->setRequired(真) ->addValidator('NotEmpty', true) ->addErrorMessage('有效'); $form->addElements(数组($email, new Zend_Form_Element_Submit('提交',array( '装饰者' => $this->buttonDecorators, '标签'=>'提交', )), )); $form->setDecorators(数组( '表单元素', array('HtmlTag', array('tag' => 'table','align'=>'center','class'=>'tbcss','width'=>'100%','边框'=>1)), '形式', ));
$this->view->assign('form',$form);
$this->_helper->layout->disableLayout();if($request->isPost())
{
print_r($request->getPost());
}
是我的装饰器:
公共 $textbox = 数组(
'ViewHelper', '表单元素', array(array('data' => 'HtmlTag'),array('tag' => 'td', 'class' =>
'元素','宽度'=>'43%','valign'=>'顶部')),
<前><代码>'错误', array(array('closeLabel' => 'HtmlTag'),array('tag' => 'td','closeOnly' => true, '放置' => '前置')), '标签',array(array('openLabel' => 'HtmlTag'),array('tag' => 'td', >'openOnly'=>true,'align'=>'right', 'valign'=>'顶部','宽度'=>'15%')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr')), );
公共$buttonDecorators =数组(
'ViewHelper', '错误', '表单元素', array('HtmlTag', array('tag' => 'td','align'=>'center','colspan'=>'2')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')), );
可以任何人都可以帮助我。
I am creating a Zend form.
when i have submit the form then error messages are not showing. It seems that validator is never triggered. This is my code:
$form = new Zend_Form;
$form->setMethod('POST') ->setAttrib('Name','pwdfrm') ->setAttrib('Id','pwdfrm'); $email = new Zend_Form_Element_Text('email'); $email->setLabel('Email :') ->setDecorators($this->textbox) ->setRequired(true) ->addValidator('NotEmpty', true) ->addErrorMessage('In valid'); $form->addElements(array($email, new Zend_Form_Element_Submit('submit',array( 'decorators' => $this->buttonDecorators, 'Label'=>'Submit', )), )); $form->setDecorators(array( 'FormElements', array('HtmlTag', array('tag' => 'table','align'=>'center','class'=>'tbcss','width'=>'100%','border'=>1)), 'Form', ));
$this->view->assign('form',$form);
$this->_helper->layout->disableLayout();if($request->isPost())
{
print_r($request->getPost());
}
And this is my decorators:
public $textbox = array(
'ViewHelper', 'FormElements', array(array('data' => 'HtmlTag'),array('tag' => 'td', 'class' =>
'element','width'=>'43%','valign'=>'top')),
'Errors', array(array('closeLabel' => 'HtmlTag'),array('tag' => 'td','closeOnly' => true, 'placement' =>'prepend')), 'Label',
array(array('openLabel' =>'HtmlTag'),array('tag' =>'td', >'openOnly'=>true,'align'=>'right','valign'=>'top','width'=>'15%')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr')), );
public $buttonDecorators = array(
'ViewHelper', 'Errors', 'FormElements', array('HtmlTag', array('tag' => 'td','align'=>'center','colspan'=>'2')), array(array('row' => 'HtmlTag'), array('tag' => 'tr')), );
can anyone help me plz.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你错过了
好运:-)
I think you missed
Good Luck :-)