ZF-7835: Label-Decorator produces invalid id with Array-Notation/subform and numeric indices
Description
When using multiple elements in a subform with numeric names (ids) the label decorator will create an id like "14-label", buts thats not valid. Its also not possible to change this behavior, because its hardcoded in Decorator/Label.php:317
$decorator->setOptions(array('tag' => $tag,
'id' => $this->getElement()->getName() . '-label'));
In the input-tag of the subform-element the name of the subform itself is prepended. This should be also here.
Comments
Posted by Sebastian Krebs (kingcrunch) on 2009-09-12T09:24:32.000+0000
This can be a solution: It prepends the Array name (if exists) before the id of the label.
Zend/Form/Decorator/Label.php:316-...
Posted by Jack Tanner (jacktanner) on 2009-10-30T09:06:43.000+0000
VERIFIED. The current behavior produces invalid XHTML.
The right kind of thing to do is to generate the label $id not based on $element->getName but on getFullyQualifiedName, but the array notation uses brackets which are invalid values for id attributes.
Posted by Sasa Stamenkovic (umpirsky) on 2009-11-20T02:17:37.000+0000
@Jack Tanner Brackets can be replaced with dashes.
Posted by Frank Brückner (frosch) on 2012-07-13T07:36:50.000+0000
Hi Sebastian, can you give a short example? Has the subform a numeric name or the element?
Thanks!
Posted by Sebastian Krebs (kingcrunch) on 2012-07-13T07:44:13.000+0000
Sorry, but was 3 years and 3 minor-versions ago...
But as far as I can see in my own repot: The element has the numeric name
Posted by Frank Brückner (frosch) on 2012-07-13T09:00:59.000+0000
Okay, I'll write an unit test.
Thanks for your very quick answer!
Posted by Frank Brückner (frosch) on 2012-07-13T10:17:04.000+0000
Here is an unit test:
' . 'Foo' . PHP_EOL . PHP_EOL . ''; $this->assertEquals($expected, $actual); }Result:
Posted by Frank Brückner (frosch) on 2013-02-12T08:22:04.000+0000
The problem was fixed in a previous version.