ZF-2989: DtDdWrapper is not xhtml valid

Issue Type: Patch Created: 2008-03-28T09:21:45.000+0000 Last Updated: 2010-05-06T04:24:54.000+0000 Status: Resolved Fix version(s): - 1.5.2 (15/May/08)

  • 1.10.5 (26/May/10)

Reporter: Dimitri van Hees (s481797) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: - ZF-3339

Attachments: - dt1.html


The empty definition term which is placed using Zend_Form when no label is specified (for example a submit button) is not XHTML valid. Therefore I suggest that, if the doctype is set to XHTML, the wrapper either doesn't place the empty definition term

, or places a nonbraking space inside it .


Posted by Wil Sinclair (wil) on 2008-03-31T15:32:41.000+0000

Please evaluate and categorize as necessary.

Posted by Matthew Weier O'Phinney (matthew) on 2008-04-22T10:31:09.000+0000

Scheduling for next mini release.

Posted by Matthew Weier O'Phinney (matthew) on 2008-04-25T11:08:47.000+0000

fixed in trunk and release-1.5 branch as of r9310.

Posted by Robin Skoglund (robinsk) on 2008-10-08T18:44:26.000+0000

The situation described is not invalid XHTML, and the non-breaking space should be removed again.

Posted by Dimitri van Hees (s481797) on 2008-10-09T00:53:00.000+0000

uhm... yes it is invalid..?

Posted by Robin Skoglund (robinsk) on 2008-10-09T04:01:52.000+0000

Where does it say it's valid? I am unable to find a source that backs up your statement, and according to the W3C validator the document is valid. You shouldn't just say "umh, yes it is invalid?" without backing it up.…

Posted by Robin Skoglund (robinsk) on 2008-10-09T04:11:08.000+0000

Also, the reason I'm complaining is this: With an empty

, the element is not rendered, and the ... below will position itself where the dt element would be, whereas with the dt element renders and takes up visual space on the page. This means that by default you get a notable gap between the last form element and the submit button, which looks odd (it looks like the form is missing something), and if you care about visual design you have to turn to various hacks to "remove the gap". Far from ideal.

Posted by Matthew Weier O'Phinney (matthew) on 2008-10-09T06:38:51.000+0000


Posted by Robin Skoglund (robinsk) on 2008-10-09T06:43:10.000+0000

The attached file passes W3C validation.

Tip: Copy-paste the file contents into this:…

Posted by Robin Skoglund (robinsk) on 2008-10-09T06:44:53.000+0000

Sounds good, Matthew :)

Posted by Darren Lucas (vtwo) on 2009-02-13T02:12:45.000+0000

The empty definition term tag issue is probably caused from using HTML Tidy to validate, e.g running the above snippet through Tidy will show the following as an error:

<pre class="literal">
 trimming empty 

{/noformat} Tested using: [] In this regard Tidy is a bit over keen, it shouldn't be throwing errors for things that are perfectly valid. In fact HTML Tidy shouldn't really be used as a validator, unfortunately it is used by certain Firefox HTML validator plugins for this purpose. Matthews suggestion of providing a switch to the DtDdWrapper asking to insert a non-breaking space is a good solution. As well as a non-breaking space could an option to put empty comment tags be added, e.g: {/noformat} This works around the HTML Tidy issue without adding whitespace into the rendered HTML page, the non-breaking space will increase or decrease in size depending on the font size.

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-05-15T05:43:58.000+0000

The issue clearly wasn't fixed with 1.5.2 (else the issue would have been closed?) so could someone please give it a new fix version, or postpone it?

Posted by Matthew Weier O'Phinney (matthew) on 2009-05-15T06:44:15.000+0000

Setting fix version to unknown. The 1.5.2 fix version was regarding the original fix (adding the no-break space).

Posted by Christian Albrecht (alab) on 2010-04-05T08:42:52.000+0000

made a patch for converting   to   after that i detected this Issue, so i merged the other into this one. The patch is easy converted to take instead.

Posted by Christian Albrecht (alab) on 2010-04-05T09:30:52.000+0000

Because i think the argument weights, that adding whitespace into rendered html is bad, here the updated patch from SubTask

<pre class="highlight">
Index: tests/Zend/Form/SubFormTest.php
--- tests/Zend/Form/SubFormTest.php     (Revision 21740)
+++ tests/Zend/Form/SubFormTest.php     (Arbeitskopie)
@@ -130,7 +130,7 @@
         $form->addSubForm($subForm, 'foobar')
              ->setView(new Zend_View);
         $html = $form->render();
-        $this->assertContains(' ', $html);
+        $this->assertContains('', $html);
Index: tests/Zend/Form/DisplayGroupTest.php
--- tests/Zend/Form/DisplayGroupTest.php        (Revision 21740)
+++ tests/Zend/Form/DisplayGroupTest.php        (Arbeitskopie)
@@ -401,7 +401,7 @@
         $this->group->addElements(array($foo, $bar));
         $html = $this->group->render($this->getView());
-        $this->assertRegexp('#^]*> ]*>$#s', $html, $html);
+        $this->assertRegexp('#^]*>]*>$#s', $html, $html);
         $this->assertContains('assertContains('"foo"', $html);
         $this->assertContains('"bar"', $html);
@@ -415,7 +415,7 @@
         $this->group->addElements(array($foo, $bar))
         $html = $this->group->__toString();
-        $this->assertRegexp('#^]*> ]*>$#s', $html, $html);
+        $this->assertRegexp('#^]*>]*>$#s', $html, $html);
         $this->assertContains('assertContains('"foo"', $html);
         $this->assertContains('"bar"', $html);
Index: tests/Zend/Form/Element/RadioTest.php
--- tests/Zend/Form/Element/RadioTest.php       (Revision 21740)
+++ tests/Zend/Form/Element/RadioTest.php       (Arbeitskopie)
@@ -168,7 +168,7 @@
                 'test' => 'Test',
         $html = $this->element->render($this->getView());
-        $this->assertRegexp('#]*> .*?assertRegexp('#]*>.*?render();
-        $this->assertContains(' ', $html);
+        $this->assertContains('', $html);
         $this->assertContains('', $html);
@@ -3773,7 +3773,7 @@
         $html = $form->render();
-        $this->assertContains(' ', $html);
+        $this->assertContains('', $html);
         $this->assertContains('', $html);
Index: library/Zend/Form/Decorator/Label.php
--- library/Zend/Form/Decorator/Label.php       (Revision 21740)
+++ library/Zend/Form/Decorator/Label.php       (Arbeitskopie)
@@ -310,7 +310,7 @@
             $options['class'] = $class;
             $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options);
         } else {
-            $label = ' ';
+            $label = '';
         if (null !== $tag) {
Index: library/Zend/Form/Decorator/DtDdWrapper.php
--- library/Zend/Form/Decorator/DtDdWrapper.php (Revision 21740)
+++ library/Zend/Form/Decorator/DtDdWrapper.php (Arbeitskopie)
@@ -57,7 +57,7 @@
         $elementName = $this->getElement()->getName();
-        return ' ' .
+        return '' .
                '' . $content . '';

Posted by Christian Albrecht (alab) on 2010-04-05T10:01:42.000+0000

Rescheduling for next Minor Release as the workarounds for the whitespace must be adapted by Developers.

Posted by Christian Albrecht (alab) on 2010-05-06T04:23:32.000+0000

Fixed in trunk r22128 and merged into 1.10 release branch.

DtDdWrapper retrieves the filler for the label now from option 'dtLabel', if this is not set defaults to ' ' //edit: stupid whitespace

<pre class="highlight">
public function render($content)
        $elementName = $this->getElement()->getName();
        $dtLabel = $this->getOption('dtLabel');
        if( null === $dtLabel ) {
            $dtLabel = ' ';

        return '' . $dtLabel . '' .
               '' . $content . '';

Have you found an issue?

See the Overview section for more details.


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

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