ZF-7134: When an dijit on a Zend_Dojo_Form_SubForm has a datastore, the generated JS to link the datastore uses the wrong ID.
Description
When an element on a Zend_Dojo_Form_SubForm has a datastore, the generated JS to link the datastore uses the wrong ID. The id's used to be in the form of subform[element], however this has been changed to subfrom-element, and the generated JavaScript does not reflect this.
Here is a test to replicate the issue:
<?php
require_once 'Zend/Controller/Action.php';
require_once 'Zend/Dojo/Form.php';
require_once 'Zend/Dojo/Form/SubForm.php';
require_once 'Zend/Dojo/Form/Element/ComboBox.php';
class TestController extends Zend_Controller_Action
{
public function dojoTestAction()
{
// Zend_Dojo_Form
$testForm = new Zend_Dojo_Form();
$testForm->setName('testform');
// Create a new subform
$testSubform = new Zend_Dojo_Form_SubForm();
// Add a test element to the subform
$testSubform->addElement(new Zend_Dojo_Form_Element_ComboBox('testcombo',
array(
'storeId' => 'testStore',
'storeType' => 'test.storeType',
'storeParams' => array(
'url' => 'test/store',
),
'label' => 'Test Label:',
)
));
// Add the subform to the main form
$testForm->addSubForm($testSubform, 'testsubform');
echo $testForm;
echo $this->view->dojo();
exit();
}
}
?>
Here is the HTML:
Test Label:
And the generated JavaScript:
As you can see in the generated javascript.:
SHOULD BE
OR The id's should actually be testsubform[testcombo], as it was previously.
Comments
Posted by Robert Hänsel (r-o-b-e-r-t) on 2009-08-18T00:52:56.000+0000
The Problem is in Zend/Dojo/View/Helper/comboBox.php:73
if (false !== ($store = $this->_renderStore($params['store'], $id))) {just replace with this ...
if (false !== ($store = $this->_renderStore($params['store'], $attribs['id']))) {Work fine for me
Posted by Fabien Faille (fa²) on 2009-08-28T02:34:51.000+0000
This bug isn't only for subforms but all elements with stores...
A very simple exemple :
rendered code
Fix given by Robert Hänsel (18/Aug/09 12:52 AM) works well, it's possible you have to make the same change on line 96...
Posted by Marcin Sikon (marphi) on 2009-09-27T13:32:41.000+0000
The bug is in file Zend/Dojo/View/Helper/ComboBox.php
148 . 'dijit.byId("' . $id . '").attr("store", ' {/noformat} should be148 . 'dijit.byId("' . $this->_normalizeId($id). '").attr("store", ' {/noformat}
Posted by Matthew Weier O'Phinney (matthew) on 2009-10-15T10:00:37.000+0000
Fixed in trunk and 1.9 release branch.