ZF-11035: adding a class to the DT element on default form decorators
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.
Comments
Posted by Kai Uwe (kaiuwe) on 2011-02-08T07:37:34.000+0000
Hi Matthieu, I can not reproduce your problem.
FooCallback and ViewScript are also default decorators.
Posted by Matthieu Larcher (mattso) on 2011-02-08T08:26:51.000+0000
Hi Kai,
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
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!
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!" ?
Posted by Matthieu Larcher (mattso) on 2011-02-24T06:32:37.000+0000
patch for the test
Posted by Matthew Weier O'Phinney (matthew) on 2011-03-01T10:28:16.000+0000
Matthieu -- he means that until the patch is applied, you shouldn't close it. :)
Posted by Matthew Weier O'Phinney (matthew) on 2011-03-01T10:41:55.000+0000
Patches applied to trunk and 1.11 release branch.
Posted by Matthieu Larcher (mattso) on 2011-03-01T10:45:42.000+0000
Thanks for the info, Matthew. That link was very tempting ;) Perhaps it'd be better just not to have the power to close/resolve at all, then, if we can't fill all the requirements to do so.
Posted by Matthieu Larcher (mattso) on 2011-03-01T10:46:44.000+0000
Sweet :) Thanks man, you just officalized my first contribution.
Posted by Matthieu Larcher (mattso) on 2011-03-07T01:57:19.000+0000
new patch from current version integrating the tagClass option in the comments
Posted by Matthieu Larcher (mattso) on 2011-03-07T01:58:58.000+0000
please someone integrate this new patch so that the added option is described in the class comments
Posted by Matthieu Larcher (mattso) on 2011-04-18T12:43:53.000+0000
anyone to push that ?