Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's an alternative to Romans that I've tried. It uses $this->api->memorize to store a GET variable chosen in the drop down list in a session variable. Then in the Form, you can set default the chosen value by using recall in the model.</p> <p>Something like this</p> <p>in page/things</p> <pre><code> // load the javascript function (see later) $this-&gt;js()-&gt;_load('your_univ'); /*****************************************************************/ /* Code to populate drop down lists - amend where as required*/ $catList=$this-&gt;api-&gt;db-&gt;dsql()-&gt;table('category c') -&gt;field('c.id') -&gt;field('c.name') -&gt;where('c.type',$cat_type) -&gt;order('c.id') -&gt;do_getAssoc(); // Check if one is set on URL or default from config and memorize the value if ($_GET['cat']){ $cat=$_GET['cat']; } else { $cat=$this-&gt;api-getConfig('idCat'); } $this-&gt;api-&gt;memorize('category',$cat); $f=$p-&gt;add('Form',null,null,array('form_empty')) -&gt;setFormClass('horizontal bottom-padded'); $l1=$f-&gt;addField('dropdown','category')-&gt;setValueList($catList)-&gt;set($cat); // calls a bit of javascript described later to reload with the parameter $l1-&gt;js('change')-&gt;univ()-&gt;yourfunc($p-&gt;api-&gt;getDestinationURL(null), $l1); .. rest of your page code goes here .. </code></pre> <p>Then in /lib/Model/Category.php</p> <p>Add the following recall for the field</p> <pre><code> $this-&gt;addField('idCat')-&gt;system(true)-&gt;visible(false) -&gt;defaultValue($this-&gt;api-&gt;recall('category')); </code></pre> <p>Note the system(true) and visible(False) means it wont show up and wont be changeable on the CRUD but you can play around with the options so it shows in the CRUD grid but not in the form.</p> <p>Finally, the little bit of javascript to make the reload work (Romans might advise a better way to do this). Make sure yourfunc matches in the page and in the js.</p> <p>in /templates/js/your_univ.js add the following</p> <pre><code> $.each({ yourfunc: function(url, name){ document.location.href=url+'&amp;cat='+$(name).val(); }, },$.univ._import); </code></pre> <p>I've got code similar to this working in my own pages. You can probably make it work as a POST as well as the drop down is a form if you dont want the cat to show on the URL.</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.
    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