Issues

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

Description

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.

Comments

A quick workaround for this is to add:

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

{quote}

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();
    $form->setName('foo');
    $form->setMethod(Zend_Form::METHOD_GET);
    $form->removeDecorator('HtmlTag');

    // Set doctype
    $this->getView()->getHelper('doctype')->doctype(
        Zend_View_Helper_Doctype::XHTML1_STRICT
    );

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

    $this->assertSame(
        $expected,
        $form->render($this->getView())
    );
}

Result: Tests passed