Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Dojo FilteringSelect from joined tables How can this be done with Doctrine
    primarykey
    data
    text
    <p>I have a number of FilteringSelect elements within my Zend Framework application that are working fine but they are based on simple queries.</p> <p>I now need to create a FilteringSelect that will allow me to select the id of one table while displaying the text of field in a related table, i.e. I have two tables groomservices and groomprocedures which are related (i.e. groomprocedures.groomProceduresID has many groomservices.procedure). The form I'm trying to create is for an appointments table which has many groomservices.groomServicesID values. I want the user to be able to see the name of the procedure while saving the value of the groomservices.groomServicesID using the FilteringSelect.</p> <p>So far I've not been able to do this in that my FilteringSelect displays nothing, I'm sure this can be done just that the fault is with my inexperience with Zend,Doctrine and Dojo</p> <p>I'm not sure if my problem is with my autocomplete action(including the query) or with the FilteringSelect element.</p> <p>Can anyone spot where I've gone wrong in the code sections below, I need to get this working.</p> <p>My autocomplete action within my controller</p> <pre><code>public function gserviceAction() { // disable layout and view rendering $this-&gt;_helper-&gt;layout-&gt;disableLayout(); $this-&gt;getHelper('viewRenderer')-&gt;setNoRender(true); // get a list of all grooming services IDs and related procedures $qry= Doctrine_Query::create() -&gt;select('g.groomServicesID,p.groomProcedure') -&gt;from('PetManager_Model_Groomservices g') -&gt;leftJoin('g.PetManager_Model_Groomprocedures p'); $result=$qry-&gt;fetchArray(); //generate and return JSON string $data = new Zend_Dojo_Data('g.groomServicesID',$result); echo $data-&gt;toJson(); } </code></pre> <p>My FilteringSelect element code</p> <pre><code> // Create a autocomplete select input for the service $gservice = new Zend_Dojo_Form_Element_FilteringSelect('gapmtService'); $gservice-&gt;setLabel('Proceedure'); $gservice-&gt;setOptions(array( 'autocomplete' =&gt; true, 'storeID' =&gt; 'gserviceStore', 'storeType' =&gt; 'dojo.data.ItemFileReadStore', 'storeParams' =&gt; array('url' =&gt; "/groomappointments/appointment/gservice"), 'dijitParams' =&gt; array('searchAttr' =&gt; 'groomProcedure'))) -&gt;setRequired(true) -&gt;addValidator('NotEmpty', true) -&gt;addFilter('HTMLEntities') -&gt;addFilter('StringToLower') -&gt;addFilter('StringTrim'); </code></pre> <p>Many thanks in advance,</p> <p>Graham</p> <p>P.S. orgot to mention I tried the following query in mysql and I gave me what I'm looking for I believe the Doctine query evaluates to the same.</p> <pre><code>select groomservices.groomservicesID,groomprocedures.groomprocedure from groomprocedures left join groomservices on groomprocedures.groomproceduresID =groomservices.groomProcedure </code></pre> <p>But I'm not sure if I formatted the query correctly in Doctrine.</p> <p>EDIT in relation to the flammon's comments</p> <p>Ok I've set the code to the following but I'm still not getting anything to display.</p> <pre><code>public function gserviceAction() { $ajaxContext = $this-&gt;_helper-&gt;getHelper('AjaxContext'); $ajaxContext-&gt;addActionContexts(array( 'gservice' =&gt; 'json' )); // get a list of all grooming services IDs and related procedures $qry= Doctrine_Query::create() -&gt;select('g.groomServicesID AS id,p.groomprocedure AS name') -&gt;from('PetManager_Model_Groomservices g') -&gt;leftJoin('g.PetManager_Model_Groomprocedures p'); $this-&gt;view-&gt;model = (object) array(); $this-&gt;view-&gt;model-&gt;identifier = 'id'; $this-&gt;view-&gt;model-&gt;label = 'name'; $this-&gt;view-&gt;model-&gt;items = array(); $tableRows = $this-&gt;dbTable-&gt;fetchAll($qry); foreach ($tableRows as $row) { $this-&gt;view-&gt;model-&gt;items[] = $row-&gt;toArray(); } } </code></pre> <p>I'm sure the fault lies with me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload