ZF-7182: Incorrect behaviour in Zend_Form_Decorator_Label
Description
The docs for this decorator state: "You may optionally specify a 'tag' option; if provided, it wraps the label in that block-level tag. If the 'tag' option is present, and no label present, the tag is rendered with no content. You can specify the class to use with the tag with the 'class' option or by calling setClass(). "
However, passing the 'class' option or calling setClass actually sets the class for the label, not the tag which wraps it, severely limiting the utility of the tag option.
Suggested fix: add a 'tagClass' option.
Comments
Posted by Mark (lightflowmark) on 2009-07-27T07:50:09.000+0000
Fix: added tagOptions option to Zend_Form_Decorator_Label. These options are then passed to the HtmlTag decorator which wraps the label tag. These options do not overwrite the tag or id options specified in Zend_Form_Decorator_Label::render
Also attached is a test for this change.
This is my first patch / test so any feedback welcome.
Posted by Peter Sharp (stryks) on 2009-08-06T06:15:49.000+0000
I wonder if the existing options should be updated to reflect the tagOptions functionality instead of actually adding tagOptions.
When specifying the label, you can set all of the class / id / etc attributes as you wish. I don't know if there is really a need for two interfaces to a single set of attributes.
Just a thought.
Posted by Mark (lightflowmark) on 2009-08-06T10:24:22.000+0000
You can set the attributes (class, etc.) for the label in the existing options; what you cannot currently do is set the attributes for the optional tag which wraps the label. Further, the docs state that you can set the tag class using setClass() - this is not true.
So you can currently create markup like:
What the docs state you can do, and my patch implements, is to create markup like
And my patch also allows you to have arbitrary attributes to the tag like
Cheers, Mark
Posted by Frank Brückner (frosch) on 2012-04-26T12:27:40.000+0000
There is already a solution: {{Zend_Form_Decorator_Label::setTagClass()}}
You can find an example here: zfforum.de (in German)