Welcome Guest, Not a member yet? Register   Sign In
set_radio() function not repopulating my radio buttons. Can't figure out why
#1

[eluser]iamzvonko[/eluser]
Hello,

I have a form with several radio button groups. My problem is that I can't get it to re-populate the selected radio button in each group. Here's a snippet for one of the groups. The $days variable is an array of arrays. Each array entry contains some information about a specific day.

Code:
<?php
echo "<b>Step 2: Select a date</b><br />&nbsp;&nbsp;";
foreach ($days as $day) {
  $val = $day['dateID'];
?&gt;
&lt;input type="radio" value="&lt;?php echo $val;?&gt;" name="volDate" id="volDate"
&lt;?php set_radio('volDate', $val);?&gt;/&gt;&lt;?php echo $day['day']; ?&gt;&nbsp;&nbsp;
&lt;?php } ?&gt;

For text input fields I use the set_value('name') function and it works fine. Well, it works fine as long as I have a validation rule for each text field. Found out that I had to have an empty validation rule if in fact I didn't need to validate the field just so it would get repopulated.

Thinking along this line, I thought I needed to add an empty validation rule for the radio button so I added this:
Code:
$this->form_validation->set_rules('volDate', 'Date', '');

Still no luck. When I submit the form and have to re-display it because of errors on other fields, my selected radio button is now un-selected.

Any idea how I can get around this?

Thanks!


Messages In This Thread
set_radio() function not repopulating my radio buttons. Can't figure out why - by El Forum - 01-17-2012, 08:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB