EllisLab text mark
Advanced Search
     
How to use form_radio for a multiple choice type of question
Posted: 11 November 2012 11:35 AM   [ Ignore ]
Joined: 2012-10-08
15 posts

I’m not clear on how to use the form_radio function to create a form that has 4 options, only one of which is right.

I envision have 4 radio buttons with the options, so that if one option is chosen, the others are automatically deselected.

Once the form is submitted, only the selected option gets passed….

Is that how the form_radio could work?

Thanks in advance!

 
Posted: 11 November 2012 02:05 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-10-31
47 posts
form_radio(array("name"=>"newuser","id"=>"newuser_1","value"=>"1"'checked'=>set_radio('newuser''1'TRUE)));  
 
form_radio(array("name"=>"newuser","id"=>"newuser_2","value"=>"2"'checked'=>set_radio('newuser''2'TRUE)));  
 
form_radio(array("name"=>"newuser","id"=>"newuser_3","value"=>"3"'checked'=>set_radio('newuser''3'TRUE)));  
 
form_radio(array("name"=>"newuser","id"=>"newuser_4","value"=>"4"'checked'=>set_radio('newuser''4'TRUE))); 
 
Posted: 11 November 2012 02:32 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-02-23
882 posts

A form radio works just like a select (also called dropdown) with only a different styling (and actually a different markup, but we don’t want to focus on that).

Having a dropdown only submits one value at time of submit. The same goes for radio buttons, they only submit one value on form submit.

 Signature 

ignited Community Framework (WiP)  |  Read the User’s Guide. It won’t bite.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

CI example .htaccess