QF SmartyArray with radio buttons
| From: | Jeroen Houben | Date: | Mon, 26 Jan 2004 15:04:42 +0000 |
| Subject: | QF SmartyArray with radio buttons | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10356@lists.php.net to get a copy of this message | ||
Hi,
I'm converting old QF (2.x) code so it can work with QF 3.x and make use of the SmartyArray renderer. I'm a bit puzzled as to why the following code gives me notices. I'm runnig Smarty 2.6 and the latest stable quickform 3.2.1).
<?php
require 'HTML/QuickForm.php';
require 'HTML/QuickForm/Renderer/ArraySmarty.php';
require 'Smarty/Smarty.class.php';
$form = new HTML_QuickForm;
$smarty = new Smarty;
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$institutions = array(
"1" => "Number One", "2" => "Number two",); foreach ($institutions as $instID => $instName) { $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'yes'); $radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'no'); $form->addGroup($radio, 'conn_allowed['.$instID.']'); unset($radio); } $form->accept($renderer); ?> What I hope to achieve is HTML output that looks like this: <table> <tbody> <tr>
<td> </td>
<th nowrap="nowrap"> Can connect to NREN </th>
</tr>
<tr>
<td> Universities </td>
<td style="text-align: center;"> <input value="yes" type="radio" name="conn_allowed[1]"
checked="checked">
Yes
<input value="no"
type="radio" name="conn_allowed[1]">
No </td>
</tr>
<tr>
<td> Institutes of higher/further education </td>
<td style="text-align: center;"> <input value="yes" type="radio" name="conn_allowed[2]"
checked="checked">
Yes
<input value="no"
type="radio" name="conn_allowed[2]">
No </td>
</tr>
<tr>
<td> Research institutes </td>
<td style="text-align: center;"> <input value="yes" type="radio" name="conn_allowed[3]"
checked="checked">
Yes
<input value="no"
type="radio" name="conn_allowed[3]">
No </td>
</tr>
<tr>
<td> Secondary schools </td>
<td style="text-align: center;"> <input value="yes" type="radio" name=
"conn_allowed[4]">
Yes
<input value="no"
type="radio" name="conn_allowed[4]" checked="checked">
No </td>
</tr>
<tr>
<td> Primary schools </td>
<td style="text-align: center;"> <input value="yes" type="radio" name=
"conn_allowed[5]">
Yes
<input value="no"
type="radio" name="conn_allowed[5]" checked="checked">
No </td>
</tr>
<tr>
<td> Libraries </td>
<td style="text-align: center;"> <input value="yes" type="radio" name="conn_allowed[6]"
checked="checked">
Yes
<input value="no"
type="radio" name="conn_allowed[6]">
No </td>
</tr>
<tr>
<td> Hospitals (other than University hospitals) </td>
<td style="text-align: center;"> <input value="yes" type="radio" name="conn_allowed[7]"
checked="checked">
Yes
<input value="no"
type="radio" name="conn_allowed[7]">
No </td>
</tr>
<tr>
<td> Government departments </td>
<td style="text-align: center;"> <input value="yes" type="radio" name=
"conn_allowed[8]">
Yes
<input value="no"
type="radio" name="conn_allowed[8]" checked="checked">
No </td>
</tr>
<tr>
<td> Others </td>
<td style="text-align: center;"> <input value="yes" type="radio" name=
"conn_allowed[9]">
Yes
<input value="no"
type="radio" name="conn_allowed[9]">
No </td>
</tr>
</tbody>
</table>
note: above HTML was generated using QF 2.x without the use of any renderers.
Any ideas on how I would be able to do that using QF3 and the Smarty renderer? Do I need a different renderer?
TIA,
Jeroen