Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using codeigniter and I have this problem.

There an array of radio button like below:

<input type="radio" name="title[0]" value="Mr."> Mr.
<input type="radio" name="title[0]" value="Ms."> Ms.
<input type="radio" name="title[0]" value="Mrs."> Mrs.
<input type="radio" name="title[0]" value="Dr."> Dr.
<input type="radio" name="title[0]" value="Prof."> Prof.

<input type="radio" name="title[1]" value="Mr."> Mr.
<input type="radio" name="title[1]" value="Ms."> Ms.
<input type="radio" name="title[1]" value="Mrs."> Mrs.
<input type="radio" name="title[1]" value="Dr."> Dr.
<input type="radio" name="title[1]" value="Prof."> Prof.

Of course they are not created manually, but using "for"

In the controller, there is a validation like this:

$this->form_validation->set_rules('title[]', 'Title', 'trim|required|xss_clean');

The strange thing is, after I choose a title in radio button with name title[0], it is considered valid eventhough title[1] is not chosen. Is this codeigniter's bug? Please help.

share|improve this question
 
If you submit one element, it's valid since you're checking if the array is not empty; so you should either use a callback function which you make yourself OR use the key in the validation & have multiple rules. –  ahmad Apr 14 '13 at 14:24
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.