如何在社交引擎的控制器中添加表单元素
How To Add Form Element in Controller in Social Engine
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')),
)
));
}
}
试试这个代码
$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')),
)
));
执行此操作的正确方法是编辑 /application/modules/Modulename/Form/Fromname.php
中的文件并使用 addElement
向表单添加特定元素。在控制器中构建表单并不是最佳的 SE 编程实践。
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')),
)
));
}
}
试试这个代码
$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')),
)
));
执行此操作的正确方法是编辑 /application/modules/Modulename/Form/Fromname.php
中的文件并使用 addElement
向表单添加特定元素。在控制器中构建表单并不是最佳的 SE 编程实践。