Details
Description
Zend_Dojo_Form_Element_ComboBox doesn't works with zend_dojo_dataStore.
It looks like combobox doesn't call fetch metod of datastore
form class
<?php
require_once ('Zend/Dojo/Form.php');
class Mats_Models_Forms_Test extends Zend_Dojo_Form {
public function init(){
$select = $this->createElement('ComboBox','test',
array(
'label'=>'test1',
'storeId'=>'bla',
'storeType'=>'dojo.data.ItemFileReadStore',
'storeParams'=>array('url'=>'/Mats/JsonSvc/deliver'),
'dijitParams'=>array('searchAttr'=>'name'),
)
);
$this->addElements(array($select));
}
}
?>
view
<?$this->layout()->setLayout('djform2')?> <?=$this->form?>
layout
<?php /** * Default Layout * * @author * @version */ echo '<?xml version="1.0" encoding="UTF-8" ?>'; echo $this->doctype(); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php $this->dojo()->setLocalPath('/scripts/dojo/dojo/dojo.js')->addStylesheetModule('dijit.themes.tundra'); echo $this->headTitle(); echo $this->headScript(); echo $this->headLink(); echo $this->headStyle(); echo $this->dojo(); ?> </head> <body class='tundra'> <?=$this->layout()->content ?> </body> </html>
json controller //Mats/Controllers/JsonSvcController.php
public function deliverAction(){ $m = new Mats_Models_ProtokoliIn(); $res = $m->fetchAll($m->select()->from($m,array('id','label'=>'deliver','name'=>'deliver'))->group('deliver')); $dj = new Zend_Dojo_Data('id',$res,'deliverStore'); //echo $m->select()->from($m,array('deliver','id'))->distinct(true); $this->_helper->autoCompleteDojo($dj); }
When i add new ComboBox via javascript it works and fetch ItemFileReadStore
w = new dijit.form.ComboBox({name:"phoneNumber",autocomplete:true, searchAttr:"name",store:bla,trim:true},"testDiv");
Generated HTML
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title><style type="text/css"> <!-- @import "/scripts/dojo/dijit/themes/tundra/tundra.css"; --> </style> <script type="text/javascript" src="/scripts/dojo/dojo/dojo.js"></script> <script type="text/javascript"> //<![CDATA[ dojo.require("dojo.data.ItemFileReadStore"); dojo.require("dijit.form.ComboBox"); dojo.require("dijit.form.Form"); dojo.require("dojo.parser"); dojo.addOnLoad(function() { dojo.forEach(zendDijits, function(info) { var n = dojo.byId(info.id); if (null != n) { dojo.attr(n, dojo.mixin({ id: info.id }, info.params)); } }); dojo.parser.parse(); }); dojo.addOnLoad(function() { bla = new dojo.data.ItemFileReadStore({"url":"\/Mats\/JsonSvc\/deliver"}); }); var bla; var zendDijits = [{"id":"test","params":{"store":"bla","searchAttr":"name","trim":"true","dojoType":"dijit.form.ComboBox"}},{"id":null,"params":{"dojoType":"dijit.form.Form"}}]; //]]> </script></head> <body class='tundra'> <form><dl class="zend_form_dojo"> <dt><label for="test" class="optional">test1</label></dt> <dd> <input options="" listsep="<br />" id="test" name="test" value="" type="text" /></dd></dl></form><script type="text/javascript"> var w; function testDojo(){ w = new dijit.form.ComboBox({name:"phoneNumber",autocomplete:true, searchAttr:"name",store:bla,trim:true},"testDiv"); } function testValue(){ alert(w.getValue()); } </script> <a href="javascript:void(0)" onclick="testDojo()">test</a> <a href="javascript:void(0)" onclick="testValue()">test2</a> <div id="testDiv"></div> <div id="consol"></div> </body> </html>
This has been reported already, and is due to a bugfix in 1.7.6. I am hoping to get a fix in for 1.7.7, but it may not make it until 1.7.8.