class Module_PhotoController extends Core_Controller_Action_Standard
{
public function nameAction()
{
$this->view->form = $form = new Modulename_Form_Fromname();
$this->addElement('Text', 'sender', array(
'label' => 'Send to',
'maxlength' => '40',
'filters' => array(
//new Engine_Filter_HtmlSpecialChars(),
'StripTags',
new Engine_Filter_Censor(),
new Engine_Filter_StringLength(array('max' => '63')),
)
));
}
}
答案 0 :(得分:3)
试试此代码
$form->addElement('Text', 'sender', array(
'label' => 'Send to',
'maxlength' => '40',
'filters' => array(
//new Engine_Filter_HtmlSpecialChars(),
'StripTags',
new Engine_Filter_Censor(),
new Engine_Filter_StringLength(array('max' => '63')),
)
));
答案 1 :(得分:1)
执行此操作的正确方法是编辑/application/modules/Modulename/Form/Fromname.php
中的文件并使用addElement
向表单添加特定元素。在控制器中构造表单并不是最好的SE编程实践。