Closed excennfahnfah1976 closed 10 years ago
I would create a new view helper, extend the localeMenu helper and use that one instead. The only thing you need to extend is this part.
In your config:
'view_helpers' => array(
'factories' => array(
'localecombobox' => 'MyModule\Service\LocaleComboboxViewHelperFactory',
),
),
Then you factory:
namespace MyModule\Service;
use MyModule\View\Helper\LocaleCombobox;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class LocaleComboboxViewHelperFactory implements FactoryInterface
{
/**
* @param ServiceLocatorInterface $serviceLocator
* @return LocaleMenu
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$detector = $serviceLocator->getServiceLocator()->get('SlmLocale\Locale\Detector');
$helper = new LocaleCombobox;
$helper->setDetector($detector);
return $helper;
}
}
Then your helper:
namespace MyModule\View\Helper;
use SlmLocale\View\Helper\LocaleMenu;
class LocaleCombobox extends LocaleMenu
{
public function __toString()
{
// here your code
}
}
ok thank you very much
Sorry one question. I get this error : Fatal error: Class 'Application\View\Helper\Locale' not found in /var/www/zf2-tutorial/module/Application/src/Application/View/Helper/LocaleCombobox.php on line 15
Ah you need to import Locale as well. Put use Locale;
just below the namespace declaration.
Thank you, it work very good ;)
How can i render locales in a combobox. i use "$this->LocaleMenu()" this view helper but i want to show a combobox not ul list.