Darren Black
2012-07-30 02:35:38 UTC
I would like to add an 'id' attribute to a menu's <ul> tag, which i can do
easily from the builder method, using setChildrenAttribute:
public function mainMenu(FactoryInterface $factory, array $options)
{
$menu = $factory->createItem('root');
$menu->addChild('Telephone Directory', array('route' => 'home'));
$menu->setChildrenAttribute('id', 'main_menu');
return $menu;
}
But, i would like set the id for the menu in the template. There appears a
way to pass options from the template to the builder, in the 2nd parameter
in knp_menu_render:
{{ knp_menu_render('AcmeSomeBundle:Builder:mainMenu', {'id':
'main_menu'}) }}
But, the options set here don't make it to the mainMenu builder method -
$options comes in as an empty array. What am I doing wrong - how can i
populate the options parameter in the builders mainMenu method?
thanks
db
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
easily from the builder method, using setChildrenAttribute:
public function mainMenu(FactoryInterface $factory, array $options)
{
$menu = $factory->createItem('root');
$menu->addChild('Telephone Directory', array('route' => 'home'));
$menu->setChildrenAttribute('id', 'main_menu');
return $menu;
}
But, i would like set the id for the menu in the template. There appears a
way to pass options from the template to the builder, in the 2nd parameter
in knp_menu_render:
{{ knp_menu_render('AcmeSomeBundle:Builder:mainMenu', {'id':
'main_menu'}) }}
But, the options set here don't make it to the mainMenu builder method -
$options comes in as an empty array. What am I doing wrong - how can i
populate the options parameter in the builders mainMenu method?
thanks
db
--
If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en