我阅读了许多关于如何在 zend 框架中的表格中制作表格的教程,但不幸的是,它们都没有为我工作,我已经花了很多时间在上面,所以我决定问你们。这是我的代码:
public $elementDecorators = array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'col2')),
array('Label', array('tag' => 'td','class'=>'taR')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr','class' => 'rowA')),
);
public function init()
{
$this->setName('message');
$message_id = new Zend_Form_Element_Hidden('message_id');
$message_id->addFilter('Int');
$message_content = new Zend_Form_Element_Text('message_content');
$message_content->setLabel('Message')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty')
->setAttrib('class', 'frmtb');
$username = new Zend_Form_Element_Text('username');
$username->setLabel('Name')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty')
->setAttrib('class', 'frmtb');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton')
->setAttrib('class', 'frmbtn');
//$this->addElements(array($message_id, $username,$message_content, $submit));
$this->addElement($username,'username',array('decorators' => $this->elementDecorators));
$this->addElement($message_content,'message_content',array('decorators' => $this->elementDecorators));
$this->addElement($submit,'submit',array('decorators' => $this->elementDecorators));
}
你能告诉我我做错了什么吗?