Selaa lähdekoodia

ZF-7134: normalize element id when generating data store selector

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18548 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 vuotta sitten
vanhempi
commit
35e2cd2d61

+ 1 - 1
library/Zend/Dojo/View/Helper/ComboBox.php

@@ -145,7 +145,7 @@ class Zend_Dojo_View_Helper_ComboBox extends Zend_Dojo_View_Helper_Dijit
                     . 'new ' . $storeParams['dojoType'] . '('
                     .     Zend_Json::encode($extraParams)
                     . ");\n"
-                    . 'dijit.byId("' . $id . '").attr("store", '
+                    . 'dijit.byId("' . $this->_normalizeId($id) . '").attr("store", '
                     . $storeParams['jsId'] . ');';
                 $js = "function() {\n$js\n}";
                 $this->dojo->prependOnLoad($js);

+ 20 - 0
tests/Zend/Dojo/Form/Element/ComboBoxTest.php

@@ -169,6 +169,26 @@ class Zend_Dojo_Form_Element_ComboBoxTest extends PHPUnit_Framework_TestCase
         $html = $this->element->render();
         $this->assertContains('dojoType="dijit.form.ComboBox"', $html);
     }
+
+    /**
+     * @group ZF-7134
+     */
+    public function testComboBoxInSubFormShouldCreateJsonStoreBasedOnQualifiedId()
+    {
+        Zend_Dojo_View_Helper_Dojo::setUseProgrammatic();
+        $this->element->setStoreId('foo')
+                      ->setStoreType('dojo.data.ItemFileReadStore')
+                      ->setStoreParams(array(
+                          'url' => '/foo',
+                        ));
+
+        include_once 'Zend/Form/SubForm.php';
+        $subform = new Zend_Form_SubForm(array('name' => 'bar'));
+        $subform->addElement($this->element);
+        $html = $this->element->render();
+        $dojo = $this->view->dojo()->__toString();
+        $this->assertContains('dijit.byId("bar-foo")', $dojo, $dojo);
+    }
 }
 
 // Call Zend_Dojo_Form_Element_ComboBoxTest::main() if this source file is executed directly.