I need to create several groups of radio buttons, grouped by a concept (collapsible) but the radio buttons must have the same name so that the form only sends one selected option among all the groups
Group 1 () Radio 1 () Radio 2 () Radio 3 Group 2 () Radio 4 () Radio 5 Group 3 () Radio 6 () Radio 7
I am developing a shipping method of commerce_shipping This form is for choose a shipping service details, therefore I only generate a part of the form of the checkout page in the function that defines the details of the service, using the commerce_shipping API. I test to set the #name property for all radio buttons but I lose the form tree, and I need to keep it so that another function can receive the data. Being inside commerce_shipping I do not have absolute control either.
The question is: What Form API elements should I use?
$form['group_1'] = array ( '#type' => 'fieldset', '#title' => t('Group 1:'), '#container' => TRUE, '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['group_1']['radios'] = array ( '#title' => 'Radio 1', '#type'=>'radio', '#return_value' => '1', );
But ther resulting radio button name is group_1][radios] and the next is group_1][radios], as the name is different then they are not part of the same selection