How to use a custom form view helper in Zend Framework 2?

后端 未结 2 1697
天涯浪人
天涯浪人 2021-01-13 01:26

I wrote a form view helper, that extends the Zend\\Form\\View\\Helper\\FormMultiCheckbox and overwrites its renderOptions(...) method:



        
2条回答
  •  囚心锁ツ
    2021-01-13 02:08

    here's an example of overriding a view helper:

    http://ctrl-f5.net/php/zf2-servicemanager-custom-viewhelpers/


    Example:

    class Module {
    
        public function onBootstrap(MvcEvent $mvcEvent)
        {
            $application = $mvcEvent->getApplication();
            $serviceManager = $application->getServiceManager();
            $viewHelperManager = $serviceManager->get('ViewHelperManager');
            $viewHelperManager->setInvokableClass('formmulticheckbox', 'MyNamespace\Form\View\Helper\FormMultiCheckbox');
        }
        ...
    }
    

提交回复
热议问题