ZF2, how to create form view helper?

◇◆丶佛笑我妖孽 提交于 2019-12-31 03:31:07

问题


I want to change the way ZF2 shows the form elements. I think I have to create my own view helper but I don't know how. I Googled for it but didn't find any useful resource.


回答1:


See the SourceCode of existing Zend\Form\View\Helper*

Basically you extend those and overwrite the required functions of stuff you want to modify.

After that you'll need to register your very own view helper. This is easily done within Module.php's getViewHelperConfig()

public function getViewHelperConfig() 
{
    return array(
        'invokables' => array(
            'customViewHelperCallName' => 'Namespace\Form\View\Helper\Classname'
        )
    );
}


来源:https://stackoverflow.com/questions/13886032/zf2-how-to-create-form-view-helper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!