Issues

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

Issue Type: Bug Created: 2009-04-02T22:01:58.000+0000 Last Updated: 2012-04-26T08:13:20.000+0000 Status: Closed Fix version(s): Reporter: Gustavo Campos (guhcampos) Assignee: Frank Brückner (frosch) Tags: - Zend_Form

Related issues: - ZF-10791

Attachments: - Form.php

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

Posted by Nick Pack (nickpack) on 2009-06-23T07:48:33.000+0000

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

Posted by Nick Pack (nickpack) on 2009-06-23T07:49:36.000+0000

Apologies, didnt think JIRA would try to parse it!

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

Posted by Nick Pack (nickpack) on 2009-06-23T07:54:05.000+0000

Class with workaround outlined in my previous comment

Posted by Frank Brückner (frosch) on 2012-04-26T08:11:13.000+0000

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

Here is an unit test:

<pre class="highlight">
/**
 * @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

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts