[eluser]insub2[/eluser]
I was wondering how to require that a radio be selected if there is no default value. Because in order for the Form Validation Class to check a field, it needs to be in the $_POST array. But if none of the radio buttons are selected, then no key will be inserted into the $_POST array.
From the view:
Code:
<?=form_radio(array( 'name'=>overall,
'id'=>'overall-one',
'value'=>'one',
'checked'=>($returned=='one')? TRUE : FALSE
)
);?>
<?=form_radio(array( 'name'=>overall,
'id'=>'overall-two',
'value'=>'one',
'checked'=>($returned=='two')? TRUE : FALSE
)
);?>
From the controller:
Code:
$this->form_validation->set_rules('overall','Overall Rating','required')
But if the form is submitted without either selected, I just get an error:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined index: overall
Filename: forms/rate.php
Line Number: 99
And the print_r($_POST) shows no 'overall':
Code:
Array
(
[category] =>
[review_title] =>
[review_details] =>
[submit] => Submit
)
What do I do?
p.s. I don't want to set a default value.