Re: [SMARTY] Is possible to create this html source with Smarty
| From: | Bertrand Zuchuat | Date: | Wed, 12 Jan 2005 10:28:01 +0000 |
| Subject: | Re: [SMARTY] Is possible to create this html source with Smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12150@lists.php.net to get a copy of this message | ||
Le 12 janv. 05, à 10:52, Dasa a écrit :
<select name="blah">
<optgroup label="Options 1"></optgroup>
<option value="11">Options 11</option>
<option value="12">Options 12</option>
<optgroup label="Options 2"></optgroup>
<option value="21">Options 11</option>
<option value="22">Options 22</option>
</select>
Hello,
<select name="blah">
{foreach key=key item=values from=blah}
<optgroup label="">{$key}</optgroup>
{foreach key=lkey item=item from=values}
<option value="{$lkey}">{$item}</option>
{/foreach}
{/foreach}
with this array
$values = array(
'option 1' => array('11' => 'Options 11', '12' => 'Options 12'),
'option 2' => array('21' => 'Options 21', '22' => 'Options 22'),
...
);
$tpl->assign($blah, $values);
Bye
Bertrand