【问题标题】:How To Add Form Element in Controller in Social Engine如何在社交引擎的控制器中添加表单元素
【发布时间】:2016-10-18 10:39:54
【问题描述】:
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')),
            )
        ));
    }
}  

【问题讨论】:

    标签: php frameworks socialengine


    【解决方案1】:

    试试这个代码

    $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')),
                )
        ));
    

    【讨论】:

      【解决方案2】:

      执行此操作的正确方法是编辑 /application/modules/Modulename/Form/Fromname.php 中的文件并使用 addElement 将特定元素添加到表单中。在控制器中构建表单并不是最好的 SE 编程实践。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-06-26
        • 1970-01-01
        • 1970-01-01
        • 2012-11-04
        • 1970-01-01
        • 2018-02-11
        • 1970-01-01
        • 2017-09-26
        相关资源
        最近更新 更多