Radio buttons field

Select one option from several radio buttons.

Return value

The internal identifier for the selected field. This is a string that does not change if even you change to names or the order of the radio buttons.

Extended Return Values

Returns an array with useful information:


// Field slug is "radiobuttonsExample"
// Returned value does not say anything about the order of the radio buttons.
// You have to print the values before knowing what value each radio button has.
// It's wierd. But it's done like that so you can change the order of the buttons
// and the names of the buttons without having to change your code.
$selected_value = simple_fields_value('radiobuttonsExample');
if ($selected_value == "radiobutton_num_3") {
    echo "You selected button two";

Output of above

You selected button two

Adding a field group with radiobuttons using PHP code

	array (
		'name' => 'Radiobuttons example',
		'fields' => array(
				'slug' => "my_radiobuttons",
				'name' => 'Select yes or no',
				'type' => 'radiobuttons',
				'options' => array(
					"values" => array(
							"num" => 0,
							"value" => "Yes",
							"checked" => true,
							"num" => 1,
							"value" => "No"
							"num" => 2,
							"value" => "Maybe"

Leave a Reply