Issues

ZF-10683: Zend_Form does not handle multiple DisplayGroups from xml file properly

Issue Type: Improvement Created: 2010-11-14T19:52:47.000+0000 Last Updated: 2012-11-20T21:37:50.000+0000 Status: Open Fix version(s): Reporter: Sebastian (sebmill) Assignee: None Tags: - Zend_Config

  • Zend_Form

Related issues: Attachments:

Description

Zend_Form's function setOptions is not capable handling multiple displayGroups when the form is created from a xml file. I used Zend_Config_Xml to access the form options and the whole form is set up like this. This is how the option representation looks like for one and two displaygroups coming from the xml:

one group

<pre class="highlight">
array(1) {
  ["DisplayGroup"] => array(3) {
    ["name"] => string(7) "contact"
    ["elements"] => array(4) {
        ["ElementName1"] => string(9) "firstname"
        ["ElementName2"] => string(8) "lastname"
        ["ElementName3"] => string(5) "email"
        ["ElementName4"] => string(6) "mobile"
    }
    ["options"] => array(1) {
      ["legend"] => string(15) "Contact Details"
    }
  }
}

two groups

<pre class="highlight"> 
array(1) {
  ["DisplayGroup"] => array(2) {
    [0] => array(3) {
      ["name"] => string(7) "contact"
      ["elements"] => array(4) {
        ["ElementName1"] => string(9) "firstname"
        ["ElementName2"] => string(8) "lastname"
        ["ElementName3"] => string(5) "email"
        ["ElementName4"] => string(6) "mobile"
      }
      ["options"] => array(1) {
        ["legend"] => string(15) "Contact Details"
      }
    }
    [1] => array(3) {
      ["name"] => string(5) "login"
      ["elements"] => array(1) {
        ["ElementName1"] => string(8) "username"
      }
      ["options"] => array(1) {
        ["legend"] => string(13) "Login Details"
      }
    }
  }
}

I created a little patch for Zend_Form which handles the displaygroups properly. The bug exists in 1.11 and 1.10.8 and probably in earlier versions as well.

Comments

Posted by Sebastian (sebmill) on 2010-11-14T20:35:38.000+0000

Patch:

Eclipse Workspace Patch 1.0

P Zend_Framework-current

Index: library/Zend/Form.php

--- library/Zend/Form.php (revision 23334) +++ library/Zend/Form.php (working copy) @@ -343,6 +343,17 @@ unset($options['displayGroupDecorators']); }

  • if (isset($options['displayGroups'])) {
  • $groups = $options['displayGroups'];
  • if (isset($groups['DisplayGroup'])) {
  • $this->setDisplayGroups($groups['DisplayGroup']);
  • }
  • else {
  • $this->setDisplayGroups($groups);
  • }
  • unset($options['displayGroups']);
  • }
  • if (isset($options['elementsBelongTo'])) { $elementsBelongTo = $options['elementsBelongTo']; unset($options['elementsBelongTo']);

Posted by Ramon Henrique Ornelas (ramon) on 2010-11-27T05:00:39.000+0000

I believe that this is improvement and not a bug. Correct me if I'm wrong

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