set_radio()

set_radio($field[, $value = ''[, $default = FALSE]])

Parameters:
  • $field (string) – Field name
  • $value (string) – Value to check for
  • $default (string) – Whether the value is also a default one
Returns:

‘checked’ attribute or an empty string

Return type:

string

Permits you to display radio buttons in the state they were submitted. This function is identical to the set_checkbox() function above.

Example:

<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'); ?> />

Note

If you are using the Form Validation class, you must always specify a rule for your field, even if empty, in order for the set_*() functions to work. This is because if a Form Validation object is defined, the control for set_*() is handed over to a method of the class instead of the generic helper function.

doc_CodeIgniter
2016-10-15 16:32:38
Comments
Leave a Comment

Please login to continue.