ZF-5033: Zend_Form_Element_Multi HTML validation warning

Issue Type: Sub-task Created: 2008-11-23T04:17:50.000+0000 Last Updated: 2010-04-05T07:42:30.000+0000 Status: Closed Fix version(s): Reporter: Daniel Egeberg (daniel0) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:


When using form elements that are descendants of Zend_Form_Element_Multi you'll get HTML validation warnings because the label will point to a non-existent ID:

Example warning message: {quote}Line 116, Column 16: reference to non-existent ID "FACILITIES".

Interior facilities: {quote} My suggestion is to drop generating a tag for such elements or at least don't give it the for attribute. Should be a pretty easy fix.


Posted by Matthew Weier O'Phinney (matthew) on 2008-11-23T06:34:14.000+0000

Actually, it's a non-trivial fix, as the Label decorator proxies to the FormLabel view helper - which requires an element name as its first argument. We may be able to pass a flag indicating that the "for" should not be rendered, however.

Which specific multi elements does this apply to? I'm fairly certain that Select and MultiSelect work properly...

Posted by Daniel Egeberg (daniel0) on 2008-11-23T06:55:55.000+0000

I only checked using MultiCheckbox, but I assumed that the other Multi descendants were affected by this as well seeing as MultiCheckbox doesn't have any code that specifically deals with the label.

Posted by Matthew Weier O'Phinney (matthew) on 2008-11-23T07:03:48.000+0000

Well, MultiCheckbox and Radio both operate differently than other Multi elements, as they generate labels per input. I think we can put the flag only in the Radio class (from which MultiCheckbox inherits), and work from there.

Posted by Michael Kliewe (mkliewe) on 2009-02-26T05:06:58.000+0000

Are you still working on this?

Invalid HTML Code isn't very nice if you want to put a "W3C Valid HTML" button on your page ;-)

Posted by Edouard Cunibil (duael) on 2010-02-10T03:45:04.000+0000

Solution posted here :…

Posted by Christian Albrecht (alab) on 2010-04-05T07:05:48.000+0000

Current trunk validates fine with

<pre class="highlight">
$form = new Zend_Form();
$form->addElement('Radio', 'Woo', array('MultiOptions' => array('foo','bar','baz')));
$form->addElement('Select', 'Zaa', array('MultiOptions' => array('foo','bar','baz')));
$form->addElement('Multiselect', 'Qua', array('MultiOptions' => array('foo','bar','baz')));
$form->addElement('MultiCheckbox', 'Qui', array('MultiOptions' => array('foo','bar','baz')));

Have you found an issue?

See the Overview section for more details.


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

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