Re: [SMARTY] html options and section
| From: | Luc Saint-Elie | Date: | Tue, 23 Apr 2002 07:40:51 +0000 |
| Subject: | Re: [SMARTY] html options and section | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-3846@lists.php.net to get a copy of this message | ||
Hello,
In term of performance I don't know, one of the advantages of html_options is when your selected index comes from a database request
An example :
I have a html_options that contains French regions :
$regionsNumero = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,25 );
$regionsNoms = array('Alsace','Aquitaine','Auvergne','Basse Normandie','Bourgogne','Bretagne','Centre','Champagne-Ardennes','Corse','Dom-Tom','Franche comté','Haute-Normandie','Ile-de-France','Languedoc-Roussillon','Limousin','Lorraine','Midi-Pyrénées','Nord-Pas-de-Calais','Pays de la Loire','Picardie','Poitou-Charentes','Provence-Alpes-Cote d\'Azur','Rhone-Alpes','International' );
$regionSelected = '13'; // this is the default value
When I have to display a user profile for example , what I want it to have as selected index, the region the user registered before
so in the PHP file :
$smarty->assign ('regionSelected', $theValueFetchedFromTheUserTable);
and in the template :
{html_options values=$regionsNumero output=$regionsNoms selected=$regionSelected}
Pretty cool, clean and convenient...
Luc
At 12:30 22/04/2002 -0400, Blue Presley wrote:
are there any advantages or disadvantages to using either {html_options} or {section}{/section} to loop through and create a <select> list for a form? thx, blue