Description

It seems there is no way simple way set pass a class on the DT element created by the default decorators.
This can be quite useful for CSS styling.
We can of course create a custom decorator, but that doesn't seem necessary, in particular when we can do this on the associated DD by passing a class option to the HtmlTag decorator of the decorated element.

We can of course use a specific list of decorators, but the goal here is to use the default ones, loaded by Zend_Form_Element::loadDefaultDecorators().

The point is to use only a simple line to pass the 'tagClass' parameter to the Label decorator automatically applied, i.e. :

$element->getDecorator('label')->setOption('tagClass', 'myClass ');

That tagClass would be used by the Label decorator when(/if) calling HtmlTag internally to add a wrapper.

Right now we can add a class to the DD definition with quite the same syntax ( $element->getDecorator('HtmlTag')->setOption('class', 'myClass'); ) so it would feel natural to be able to do this kind of thing for the DT also. P

This is way more concise than having to redeclare all default decorators manually to achieve the same goal, don't you think ?

Posted by Matthieu Larcher (mattso) on 2011-02-08T08:28:36.000+0000

Actually I already have modified the concerned file to do so, and my CLA just got validated, I just need to figure out how to submit a file. Surprisingly enough, this seems like the hard part of contributing.

Posted by Kai Uwe (kaiuwe) on 2011-02-08T08:36:11.000+0000

It was clear to me from the beginning. But why is it not in your description of the problem?

Posted by Matthieu Larcher (mattso) on 2011-02-08T08:41:31.000+0000

Seems to me it is, as long as you understand "default decorators" as the decorators being applied by default, not as the actual existing decorators in the zf lib.

Posted by Kai Uwe (kaiuwe) on 2011-02-08T09:00:20.000+0000

Standard vs. Default ;-)

Posted by Matthieu Larcher (mattso) on 2011-02-08T09:06:45.000+0000

Indeed. I stand by my 'default' ;)
Any tip on how I can post the modified Zend_Form_Decorator_Label ?

Posted by Kai Uwe (kaiuwe) on 2011-02-08T09:12:36.000+0000

I think you need first the CLA. Then you can add a file.
In the left sidebar there is a link (under the headline "functions").

Posted by Matthieu Larcher (mattso) on 2011-02-08T09:21:08.000+0000

This is a modified version of Zend_Form_Decorator_Label allowing to set a class on its DT wrapper

Posted by Matthieu Larcher (mattso) on 2011-02-08T09:25:55.000+0000

That didn't seem to me like the right place, but well... if you say so. I'll just close the ticket and see what happens then ;)

Posted by Matthieu Larcher (mattso) on 2011-02-08T09:26:57.000+0000

added the functionnality requested

Posted by Kai Uwe (kaiuwe) on 2011-02-08T09:32:41.000+0000

Not to fast!
Please add a patch file and write unit test!

Posted by Kai Uwe (kaiuwe) on 2011-02-08T09:44:13.000+0000

No unit tests

No patch file

Posted by Matthieu Larcher (mattso) on 2011-02-24T02:14:40.000+0000

the patch file

Posted by Matthieu Larcher (mattso) on 2011-02-24T03:56:08.000+0000

unit test

Posted by Matthieu Larcher (mattso) on 2011-02-24T03:57:26.000+0000

patch file and unit test done.
I guess this it it... Let me know if something is still missing

Posted by Kai Uwe (kaiuwe) on 2011-02-24T05:15:44.000+0000

Please do not close an issue when not all work is done!

Add a patch file for tests.

The comment of your method is wrong.

Posted by Kai Uwe (kaiuwe) on 2011-02-24T05:18:54.000+0000

This is a case for the component maintainer!

Posted by Matthieu Larcher (mattso) on 2011-02-24T06:29:40.000+0000

Kai,
what is wrong with the comment ?
what do you mean by "This is a case for the component maintainer!" ?