ZF2,如何创建表单视图助手? [英] ZF2, how to create form view helper?
本文介绍了ZF2,如何创建表单视图助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想改变 ZF2 显示表单元素的方式.我想我必须创建自己的视图助手,但我不知道如何.我用谷歌搜索但没有找到任何有用的资源.
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.
推荐答案
参见 现有 Zend\Form\View\Helper 的 SourceCode*
基本上你扩展这些并覆盖你想要修改的东西的必需功能.
Basically you extend those and overwrite the required functions of stuff you want to modify.
之后,您需要注册您自己的视图助手.这可以在 Module.php 的 getViewHelperConfig()
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'
)
);
}
这篇关于ZF2,如何创建表单视图助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文