Welcome Guest, Not a member yet? Register   Sign In
set_radio giving 'selected="selected"' in my html .. please help
#1

[eluser]Unknown[/eluser]
Hi there.
I'm using something like this:

form_view.php:

Code:
&lt;input type="radio" name="gender1" value="male" &lt;?php echo set_radio('gender1', 'male'); ?&gt; /&gt;&lt;span class="radio-option">male</span>
&lt;input type="radio" name="gender1" value="female" &lt;?php echo set_radio('gender1', 'female'); ?&gt; /&gt;&lt;span class="radio-option">female</span>

form_controller.php:
Code:
$this->form_validation->set_rules('gender1', 'Gender', 'trim|required|min_length[4]|max_length[100]|xss_clean');

html markup is showing as:

Code:
&lt;input type="radio" name="gender2" value="male"  /&gt;&lt;span class="radio-option">male</span>
&lt;input type="radio" name="gender2" value="female"  [color=purple]selected="selected"[/color] /&gt;&lt;span class="radio-option">female</span>

I cant get the radio buttons to stay selected.
I want the set_radio to output checked="checked" but instead it seems to be giving 'selected="selected"' in my html

Any help much appreciated. Sad
#2

[eluser]pickupman[/eluser]
Have you extended the form validation class (/application/libraries/MY_Form_validation.php)? I checked 1.7.2 and 2.0dev, and both set_radio() methods show using (checked="checked") as their output. Open /system/libraries/Form_validation.php around line 790 for the method. Make sure you see the right string returned.
#3

[eluser]Unknown[/eluser]
Hi Pickupman,
Thank you for taking the time to reply to my post.
You solved my problem.

I extended my /system/libraries/Form_validation.php as suggested by another post in the forum (i cant find it again) to help with the set_radio() function. but the code in this post wrongly has selected=“selected” instead of checked=“checked”.

Tim
#4

[eluser]pickupman[/eluser]
Whew, glad that was an easy one. Just remember when you extend a class you only to add the methods you need to modify from the core ones. I only have one method in my form validation extended class.




Theme © iAndrew 2016 - Forum software by © MyBB