Welcome Guest, Not a member yet? Register   Sign In
setting radio button value
#1

[eluser]dadamssg87[/eluser]
I'm having trouble with codeigniter's set_radio() function. I can't seem to get it to work. I have set up a simple form to try to make it work with no avail. Here is my code to display the radio buttons.

Code:
<?php
echo form_radio('calendar', 'n', set_radio('calendar', 'n', TRUE))." None<br>";
echo form_radio('calendar', '24', set_radio('calendar', '24'))." Business Profile 1<br>";
echo form_radio('calendar', '25', set_radio('calendar', '25'))." Business Profile 2<br><br>";

I should mention i have another text input above the radio buttons and have the validation rules set to throw a validation error when that field is empty so the form reloads with the submitted values still in the form(except for the radio button values). It loads up fine with the first button checked and the others not. But then when i submit the form it comes back with the empty field error and none of the radio buttons checked no matter which radio button i check.

Can anybody see what i'm doing wrong? I even tried copy pasting their example in the user guide but i didn't work either.
#2

[eluser]oppenheimer[/eluser]
I don't think you can use set_radio that way. Try this post:

http://ellislab.com/forums/viewthread/184991/
#3

[eluser]theprodigy[/eluser]
Quote:
Code:
&lt;?php
echo form_radio('calendar', 'n', set_radio('calendar', 'n', TRUE))." None<br>";
echo form_radio('calendar', '24', set_radio('calendar', '24'))." Business Profile 1<br>";
echo form_radio('calendar', '25', set_radio('calendar', '25'))." Business Profile 2<br><br>";
Can anybody see what i’m doing wrong?

Try
Code:
&lt;input type="radio" name="calendar" value="n" &lt;?php echo set_radio('calendar','n',TRUE); ?&gt; /&gt; None<br />
&lt;input type="radio" name="calendar" value="24" &lt;?php echo set_radio('calendar','24'); ?&gt; /&gt; Business Profile 1<br />
&lt;input type="radio" name="calendar" value="25" &lt;?php echo set_radio('calendar','25'); ?&gt; /&gt; Business Profile 2<br /><br />
#4

[eluser]pmoroom[/eluser]
Are you having issues having it maintain the selected value after a form is submitted but fails validation?




Theme © iAndrew 2016 - Forum software by © MyBB