I want to produce a radio button like this:
<input type="radio" name="quest0" value="a" required>
I am doing like this
echo form_radio("quest0","a");
But how can I add required attribute using Codeigniter form helper.
I am doing like this echo form_radio("quest0","a"); " /> I am doing like this echo form_radio("quest0","a"); " /> I am doing like this echo form_radio("quest0","a"); "/>
I want to produce a radio button like this:
<input type="radio" name="quest0" value="a" required>
I am doing like this
echo form_radio("quest0","a");
But how can I add required attribute using Codeigniter form helper.
On
Try this:
<input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> />
<input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> />
On
You can add other attributes like id, data-*, required in 4th parameter of form_radio() function, try this code
echo form_radio("quest0","a", false,"required id=\"quest0\"");
On
One way is to write as shown by @Shaiful Islam.
Other way is to write as below:
echo form_radio("quest0","a", FALSE, "required=required");
Refer the Source Code - Form Helper - Line 459
You are passing the other parameters as EXTRA attribute
I think you can do it this way.(I did not tested it)