我有以下表单类:
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Username:')
->setRequired(true)
->addValidator('NotEmpty')
->addFilter('StringTrim')
->setAttribs(array('class' => 'textfield'));
$submit = $this->createElement('submit', 'mySubmit');
$submit->setLabel('Login')
->setAttribs(array('id' => 'btnsubmit', 'class' => 'btn'));
$reset = $this->createElement('reset', 'myReset');
$reset->setLabel('Reset')
->setAttribs(array('id' => 'btnreset', 'class' => 'btn'));
$this->addElements(array($username, $submit, $reset));
$this->setElementDecorators(array(
'ViewHelper',
'Errors',
array('Label', array('class' => 'login_label', 'placement'=> 'REPLACE')),
array('HtmlTag', array('tag'=> 'p')),
));
$this->setDecorators(array(
'FormElements',
'Form',
array('Fieldset', array('legend' => 'Login Info')),
array(array('mydiv' => 'HtmlTag'), array('tag' =>'div', 'id' => 'lgrd')),
));
以下是动作控制器代码:
$form = new Application_Form_Adminlogin();
$this->view->form = $form;
如果我提交空白用户名字段,则页面上不会显示错误。有人可以指导我做错了什么以及如何纠正它。
提前致谢