ZF-6200: Zend_Form fails W3C check:outputs name="" tag for <form> element


W3C Validator Output:

Line 29, Column 148: Attribute "name" exists, but can not be used for this element. ...-charset="UTF-8" method="post" name="">

Relevant line:


form id="MyForm" enctype="application/x-www-form-urlencoded" action="/myaction" accept-charset="UTF-8" method="post" name="">

DOCTYPE is XHTML 1.0 STRICT, set through Zend_View_Helper_Doctype on the bootstrap, other tags show correctly etc.


A quick workaround for this is to add:

{quote} if (array_key_exists('name', $attribs)) { unset($attribs['name']); }


to Zend_View_Helper_Form::form() somewhere before the $xhtml variable is defined.

Not a particularly good workaround, but fixes validation issues

Apologies, didnt think JIRA would try to parse it!

if (array_key_exists('name', $attribs)) { unset($attribs['name']); }

Class with workaround outlined in my previous comment

The problem no longer exists: ZF-10791 (Version 1.11.8)

Here is an unit test:

 * @group ZF-6200
public function testNameAttributeOutputForXhtml()
    // Create form
    $form = new Zend_Form();

    // Set doctype

    $expected = ''
              . "\n"
              . '';


Result: Tests passed