function.html_options.php

From: Date: Thu, 04 Apr 2002 08:20:45 +0000
Subject: function.html_options.php
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-15@lists.php.net to get a copy of this message
I send an incomplete email... here is the complete Hi guys, I change the html.options custom function. Monte, please add to the oficial release. If I has a CVS account I myself could add this, but, I alright requested it. Tell-me, Monte/Andrei, the DocBook documentation is allways up-to-date at CVS or we need send the DocBook changes to someone? Now it have a new attribute called "sort". There are 4 values to sort: keys, rkeys, vals, rvals. The purpose is sort the array options. There are no default sort, if sort is NULL, the array will be unchanged. vals - sort the associative array options using asort - the key association isn't change. The array will be sorted by its values. keys - will sort the array options using the ksort, so the options will be sorted by key. rkeys - sort like keys, but in reverse order - use krsort rvals - sort like vals, but in reverse order - use arsort An example: form.tpl ---------------------------------------------------------------------------- -------------------------------- {php} global $cms; $cms->smarty->assign("customer_options",array( "c"=>"Bodinho", "b"=>"Alewin", "a"=>"Jucisoa" )); {/php} <pre> <form> Sorted by Vals: <select name=customer_id> {html_options options=$customer_options selected=$smarty.get.customer_id sort="vals"} </select> Sorted by Keys: <select name=customer_id> {html_options options=$customer_options selected=$smarty.get.customer_id sort="keys"} </select> Sorted by reverse Vals: <select name=customer_id> {html_options options=$customer_options selected=$smarty.get.customer_id sort="rvals"} </select> Sorted by reverse Keys: <select name=customer_id> {html_options options=$customer_options selected=$smarty.get.customer_id sort="rkeys"} </select> <input type=submit value="GO"> </form> </pre> ---------------------------------------------------------------------------- -------------------------------- Output: <pre> <form> Sorted by Vals: <select name=customer_id> <option value="b">Alewin</option> <option value="c">Bodinho</option> <option value="a">Jucisoa</option> </select> Sorted by Keys: <select name=customer_id> <option value="a">Jucisoa</option> <option value="b">Alewin</option> <option value="c">Bodinho</option> </select> Sorted by reverse Vals: <select name=customer_id> <option value="a">Jucisoa</option> <option value="c">Bodinho</option> <option value="b">Alewin</option> </select> Sorted by reverse Keys: <select name=customer_id> <option value="c">Bodinho</option> <option value="b">Alewin</option> <option value="a">Jucisoa</option> </select> <input type=submit value="GO"> </form> </pre>

« previous php.smarty.dev (#15) next »