Re: [SMARTY] Dynamic variables
| From: | Raul Carvalho | Date: | Tue, 29 Apr 2003 13:53:29 +0000 |
| Subject: | Re: [SMARTY] Dynamic variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-9419@lists.php.net to get a copy of this message | ||
Hi,
> Pass them in a way that is more usable by smarty:
> $sel = array();
> for ($i=0;$i<N;$i++) {
> $var = "sel_$i";
> $sel[] = $$var;
> }
> $smarty->assign('sel', $sel);
The problem was how to iterate on $sel...
Consider the following block of Smarty code:
{section name=pa loop=$pa_var}
<tr>
<td>
<select name="s_{$smarty.section.pa.index}">
{html_options values=$id output=$names selected=$sel[pa]}
</select>
</td>
</tr>
{/section}
The trick was using [pa] as dimension on $sel :-P
Thsnk you!! :-)