Issues

ZF-7663: SubForm decorators are not properly namespaced

Issue Type: Sub-task Created: 2009-08-23T01:11:03.000+0000 Last Updated: 2010-04-20T11:44:17.000+0000 Status: Resolved Fix version(s): Reporter: Tomek Pęszor (admirau) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

Related issues: - ZF-7835

Attachments: - ZF-7663.txt

Description

Here is an example which illustrates this issue: $form = new Zend_Form;

$checkbox = new Zend_Form_Element_Checkbox('checkbox1', array('label'=>'checkbox 1')); $form->addElement($checkbox); $checkbox = new Zend_Form_Element_Checkbox('checkbox2', array('label'=>'checkbox 2')); $form->addElement($checkbox);

$subform1 = new Zend_Form_SubForm('subform1');

$checkbox = new Zend_Form_Element_Checkbox('checkbox1', array('label'=>'checkbox 1')); $subform1->addElement($checkbox); $checkbox = new Zend_Form_Element_Checkbox('checkbox2', array('label'=>'checkbox 2')); $subform1->addElement($checkbox);

$form->addSubForm($subform1, 'subform1');

This produces the following HTML:

checkbox 1 checkbox 2 checkbox 1 checkbox 2 As you can see, id attributes are duplicated.

Comments

Posted by Tomek Pęszor (admirau) on 2009-08-24T05:36:26.000+0000

To fix duplicate

change in Zend_View_Helper_Label: line 317: 'id' => $this->getElement()->getName() . '-label')); to: 'id' => $id. '-label'));

I do not know, how to fix duplicates in

. This is where default HtmlTag decorator dd is added. Now to fix this, I add HtmlTag decorator with custom id.

Posted by Tomás Güemes (tguemes) on 2009-08-25T05:02:26.000+0000

To fix duplicate in

the defaults decorators are set in Zend_Form_Element: loadDefaultDecorators() line 291 (ZF 1.9.0) public function loadDefaultDecorators() { if ($this->loadDefaultDecoratorsIsDisabled()) { return; } $decorators = $this->getDecorators(); if (empty($decorators)) { $this->addDecorator('ViewHelper') ->addDecorator('Errors') ->addDecorator('Description', array('tag' => 'p', 'class' => 'description')) ->addDecorator('HtmlTag', array('tag' => 'dd')) ->addDecorator('HtmlTag', array('tag' => 'dd', 'id' => $this->getName() . '-element')) ->addDecorator('Label', array('tag' => 'dt')); } } I try to use $this->getId() instead of $this->getName() but it didn't work so i just remove the 'id' attrib from the HtmlTag decorator: ->addDecorator('HtmlTag', array('tag' => 'dd')) Cheers Tomas Guemes

Posted by Sasa Stamenkovic (umpirsky) on 2009-12-17T02:52:43.000+0000

I suggest a patch in Zend_Form_Decorator_Label to fix this issue. SVN diff attached.

Regards, Saša Stamenković

Posted by Sasa Stamenkovic (umpirsky) on 2010-04-03T03:25:21.000+0000

Why nobody is reviewing my patch. Tell me if its wrong.

Posted by Christian Albrecht (alab) on 2010-04-20T11:44:16.000+0000

Resolving as duplicate of ZF-6741.

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