ZF-7182: Incorrect behaviour in Zend_Form_Decorator_Label

Issue Type: Sub-task Created: 2009-07-02T08:09:34.000+0000 Last Updated: 2013-03-13T20:55:22.000+0000 Status: In Progress Fix version(s): - Next Mini Release ()

Reporter: Mark (lightflowmark) Assignee: Mark (lightflowmark) Tags: - Zend_Form

  • After1.12.0

Related issues: - ZF-10608

Attachments: - ZF-7182_fix.patch


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.


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:

My Label

What the docs state you can do, and my patch implements, is to create markup like

My Label

And my patch also allows you to have arbitrary attributes to the tag like

My Label

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: (in German)

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.