Here's some code that I use in my application's bootstrap logic to initialize
the behavior of the headTitle() helper:
/**
* Set up headTitle view helper -- we always want to set, not append,
titles.
*
* @return void
*/
protected function initHeadTitle()
{
$callback = function($event) {
$serviceManager = $event->getApplication()->getServiceManager();
$renderer = $serviceManager->get('viewmanager')->getRenderer();
$headTitle = $renderer->plugin('headtitle');
$headTitle->setDefaultAttachOrder(
\Zend\View\Helper\Placeholder\Container\AbstractContainer::SET
);
};
$this->events->attach('dispatch', $callback);
}
(That comes out of a bootstrap class that I call from my module's onBootstrap
method... but you get the idea). You can probably do something similar to set
translators, assuming you have access to the necessary translator object at the
time that this event triggers.
- Demian
> -----Original Message-----
> From: Ralf Eggert [mailto:[email protected]]
> Sent: Wednesday, August 22, 2012 10:07 AM
> To: [email protected]
> Subject: [fw-general] ZF2 Forms: add translator to formLabel view helper
>
> Hi,
>
> with the new formLabel view helper, I manually need to set the
> translator object with the setTranslator() / setTranslatorTextDomain()
> methods. I can set this at the top of each view script that uses a form.
>
> But I would like to set the translator for view helpers within a module
> to change the text domain depending on the module. What would be the
> best way to do this? The onBootstrap() method of my Module.php? Or some
> other place?
>
> The same problem exists for the formSelect and formMultiCheckbox view
> helpers.
>
> Regards,
>
> Ralf
>
> --
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
>
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]