[SOLVED] CreateInputRadioGroup and Smarty foreach
Posted: Tue Sep 25, 2012 12:13 pm
Hi, I'm trying to display a table with a radio button on each row.
I create the radio buttons in this way:
and I display the table with Smarty:
But I got the same value for all radiobutton:
but is there a way to achieve the same result using CreateInputRadioGroup?
Thank you
I create the radio buttons in this way:
Code: Select all
$arr_ids = array();
$entryarray = array();
while ($dbresult && $row = $dbresult->FetchRow())
{
$onerow = new stdClass();
$arr_ids[''] = $row['id'];
$onerow->name = $row['name'];
$entryarray[] = $onerow;
}
$smarty->assign_by_ref('items', $entryarray);
$smarty->assign('radios', $this->CreateInputRadioGroup($id, 'id', $arr_ids));
Code: Select all
<tbody>
{foreach from=$items item=entry}
<tr>
<td>{$radios}</td>
<td>{$entry->name}</td>
</tr>
{/foreach}
</tbody>
Of course, I can manually write in the template:<tbody>
<tr>
<td><input class="cms_radio" name="cntnt01id" id="cntnt01id1" value="3" type="radio"><label class="cms_label" for="cntnt01id1"></label></td>
<td>Jane</td>
</tr>
<tr>
<td><input class="cms_radio" name="cntnt01id" id="cntnt01id1" value="3" type="radio"><label class="cms_label" for="cntnt01id1"></label></td>
<td>John</td>
</tr>
</tbody>
Code: Select all
<td><input type="radio" name="{$form_id}id" value="{$entry->id}" /></td>
Thank you