Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.6.2

Bug #8385 html label tag useless for element without label
Submitted: 2006-08-08 10:48 UTC
From: farell Assigned: wiesemann
Status: Closed Package: HTML_QuickForm_Renderer_Tableless (version 0.3.2)
PHP Version: 4.4.2 OS: n/a
Roadmaps: (Not assigned)    
Subscription  


 [2006-08-08 10:48 UTC] farell (Laurent Laville)
Description: ------------ Even if it's not really a bug, but an improve to package to build valid xhtml page, i would like to notice that : When form has elements without label such as submit button, the html label tag is useless, and generate a warning with tidy ! - Warning: trimming empty

Comments

 [2006-08-10 17:17 UTC] wiesemann (Mark Wiesemann)
Hi Laurent, I have two questions about this report from you: - You wrote about the 'cols' attribute of the textarea element. I confirm that the W3C validator complains if it is missing. But what should I do? Maybe add ' cols="0"' if there is no 'cols' attribute? - The validator also complains about the 'name' attribute in the form tag. Do you see any problem that could occur if I remove this attribute in my renderer? Thanks, Mark
 [2006-08-10 17:35 UTC] wiesemann (Mark Wiesemann)
Hi again, I just tried to (and did) remove the empty label. Unfortunately and as I also remember from my very first implementations of this renderer, this breaks the layout. The element is left-aligned if there's no label tag. If you have ideas, on how to solve this, please share them with me. Thanks, Mark
 [2006-08-12 17:32 UTC] farell (Laurent Laville)
Well, now i've uploaded my new release of HTML_Progress2 i've time to reply to you. To solve the problem, i've found after some disappointement that the solution is not on renderElement() method as i've said in past, but into finishForm(). On file revision Tableless.php,v 1.7 2006/08/06 13:01:30 wiesemann Exp after line 250, add this one $this->_html = str_replace('></label>', '> </label>', $this->_html); and all will be fine. Hope you'll enjoy my hack that does not break the layout ! I use it even with QF default renderer To reply to your 2 questions : - 'cols' attribute It's not to you to fix it into your renderer, but to the programmer to have in mind such situation. You need only to fix your example in the bundle. - remove name attribute ? No don't do that, it's again to the programmer to do that if he want. I did it myself on all my implementations Laurent
 [2006-08-13 20:25 UTC] wiesemann (Mark Wiesemann)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/HTML_QuickForm_Renderer_Tableless --- Thanks for your valuable comments. I've used your code for the empty label replacement and updated the example file as you suggested it (and also added <html>, <head> etc. to make it easier to try out the package).
 [2006-09-16 04:47 UTC] cwiedmann (Wiedmann)
Hi Marc, two additions for this topic. a) With a simple: $form->addElement('reset', null, 'Reset'); I get: <label for="" class="qflabel"> </label> Ok, the " " is there :-). But an empty for="" is also not valid. --> for me I add now a name to the reset button too. e.g.: $form->addElement('reset', 'form_reset', 'Reset'); b) With a hierselect: $select =& $form->addElement('hierselect', 'foo', 'bar'); $select->setOptions(array($select1, $select2)); I get: <label for="foo" class="qflabel">bar</label> But the 2 selects have the names "foo[0]" / "foo[1]". Not valid. --> for me I use now a group for the hierselect: $select =& HTML_QuickForm::createElement('hierselect', null, ' '); $select->setOptions(array($select1, $select2)); $form->addGroup(array($select), 'foo', 'bar'); (now the two selects have the names "foo[0][0]" / "foo[0][1]" :-/ but it's valid :-) because no for="foo" in the label) Regards, Carsten
 [2006-09-16 20:49 UTC] wiesemann (Mark Wiesemann)
Carsten, please open a new report next time (or at least reset the status to open [maybe that's not allowed, not sure]). About your report: The "for" attribute is now only added if the label is not empty (not null or not ""), the "id" attribute is only added in the same case to the element. The example file has two new text elements (one without label [null], one with empty label [""]) to prove the XHTML validity. The other problem with the hierselect was already fixed by the fix for bug #8523 (in CVS, but not released yet). The problem was that date and hierselect element are groups but not handled like groups in QF internally. My fix now adds the "id" attribute (same as in the "for" attribute) to the first (select) element. Regards, Mark (<= mind the last letter *g*)