CodeIgniter Forums
set_radio() within a form_radio() array - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: set_radio() within a form_radio() array (/showthread.php?tid=45687)



set_radio() within a form_radio() array - El Forum - 10-01-2011

[eluser]l2eqless[/eluser]
Would it be possible to use set_radio within a form_radio array? To do this within a text input, you simply put the function in the value part of the array, however the value within a radio button is used differently.

For instance, say I have 2 radio buttons:
Code:
$radio1 = array (
'name' => 'option',
'value' => 'option1',
'checked' => TRUE,
);
$radio1 = array (
'name' => 'option',
'value' => 'option2',
'checked' => FALSE,
);
echo form_radio($radio1);
echo form_radio($radio2);

Is there any way i can manipulate that arrays above to include the set_radio() function or would I simply have to simply use the following:
Code:
<input type="radio" name="option" value="option1" <?php echo set_radio('option', 'option1'); ?> />
<input type="radio" name="option" value="option2" <?php echo set_radio('option', 'option2'); ?> />

I'm asking simply because I feel using the arrays makes it easier on the eye if I ever have to go back and edit.

Thanks for the time!