ZF-11876: Zend_View_Helper_Navigation_Menu does not render custom Page properties
Description
Zend_View_Helper_Navigation_Menu does render Page _properties as html attributes in htmlify() method. It allows only to use id, title, target, href and class like below:
$attribs['href'] = $href;
$attribs['target'] = $page->getTarget();
$attribs = array(
'id' => $page->getId(),
'title' => $title,
'class' => $page->getClass()
);
What if one wants to add "onclick" atribute for example. The only way now is to use JavaScript (perhaps it is a better solution in such case) but generally one should be able to add custom attributes. I think there should be an array_merge with Page's $_properties array?
Comments
Posted by Frank Brückner (frosch) on 2011-11-09T11:42:30.000+0000
Code tags added.
Posted by Frank Brückner (frosch) on 2011-11-09T12:00:26.000+0000
{quote}I think there should be an array_merge with Page's $_properties array?{quote} Bad idea, because not all custom page properties are also allowed HTML attributes! Look at the first example in docs:
http://framework.zend.com/manual/en/…
Posted by Frank Brückner (frosch) on 2011-11-09T22:33:30.000+0000
{quote}The only way now is to use JavaScript (perhaps it is a better solution in such case){quote} This is the best solution. We are in 2011 and inline event handlers are from the last millennium. :-) Use Unobtrusive JavaScript!
Posted by Frank Brückner (frosch) on 2012-03-22T18:56:00.000+0000
Patch and unit tests added.
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-31T23:33:36.000+0000
Frank: When I applied your patches and ran the Navigation tests I got one failure:
Posted by Frank Brückner (frosch) on 2012-06-01T06:25:59.000+0000
Hi Adam, I will check this and create a new patch.
Thanks for your work!
Posted by Frank Brückner (frosch) on 2012-06-01T12:15:02.000+0000
My result:
(?)
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-05T13:10:00.000+0000
Intriguing....Could you try applying your patches to a clean SVN trunk? When I do that, I only count 68 tests in Zend_Navigation_PageTest and I get the failure I included in my previous comment:
Posted by Frank Brückner (frosch) on 2012-06-05T13:23:25.000+0000
Sh*t! I have forgotten one patch. Sorry, my mistake.
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-06T13:05:16.000+0000
Aha! That would do it. Everything passes now :)
Posted by Adam Lundrigan (adamlundrigan) on 2012-06-06T13:09:42.000+0000
Fixed in trunk (1.12.0): r24879
Thanks, Frank!