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

[eluser]ommy[/eluser]
I'm stabbing in the dark here.
How am i supposed to set up a working validation for a few radiobuttons.

Let's say i have this in my view:
Code:
<input type="radio" name="voor" value"1"> Part one
<input type="radio" name="voor" value"2"> Part two

then i would have this in my controller:
Code:
$this->load->library('form_validation');
$this->form_validation->set_rules('voor','radio','required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('formwithradios')
}else{
echo 'hoorai';
}

The main problem i'm experiencing is that the value of the post variable is "ON" when something is selected. and false when nothing has been. I can imagine set_radio having trouble finding which radio button it should select after submitting/failing validation.
#2

[eluser]ommy[/eluser]
for some reason i wasn't getting the right response from the validation class.
I got it to work but i'm still wondering what my mistake was.
Form validation has this knack of bugging me every time i use it Smile

this is working:
Code:
<input type="radio" name="voor" value="1" <?=set_radio('voor','1',true)?> />

still registering the radio buttons:
Code:
$this->form_validation->set_rules('voor');

So if anyone would care to enlighten me what i did wrong or could've done wrong in the first place.

Thanks a bunch and sorry for my semi-irrelevant question




Theme © iAndrew 2016 - Forum software by © MyBB