I have a form that displays questions from a questionnaire. Some questions are True/False (radio buttons) but some are free text input. Each questionnaire can have any number of questions, which are stored in a lookup table along with the answer provided by the user. To take advantage of CodeIgniters form validation library, I figured I would use an array for the input names and store the primary key of the survey question as the index:
View:
<input type="radio" name="question[<?=$id;?>]" value="<?=$answer?> <?=set_radio('question['. $id . ']', $answer) ?> />
Controller:
$this->form_validation->set_rules('question[]', 'Questions', 'required');
CodeIgniter doesn't seem to validate radio buttons properly when there is no default value set. Any ideas on whether or not I am doing this correctly?