我使用验证器来测试数据库中是否存在登录并且它可以工作,但是在为 Zend 表单添加装饰器后,验证器错误消息不再显示。
编码:
$this->setName("companyadd");
$comp = new Zend_Validate_Db_NoRecordExists('company', 'name');
$comp->setMessage("This company exists!!!!");
$name = new Zend_Form_Element_Text('name');
$name->addValidator($comp);
$name->setAttrib('size', '45');
$name->setLabel('Company Name')
->setAttrib('class', 'companyinputs');
$submit = new Zend_Form_Element_Submit('submit');
$this->addElements(array( $name, $submit));
$this->setElementDecorators(
array(
'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array('Label', array('tag' => 'td', 'class' => 'companylabel')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => 'signuptr'))
));
$submit->setDecorators(
array(
'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array(array('emptyrow' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element', 'placement' => 'PREPEND')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
));
$this->setDecorators(
array(
'FormElements',
array('HtmlTag', array('tag' => 'table', 'class' => 'signuptable')),
'Form'
));