I have a need for custom defined radio button groups. The second radio button group is visible when a certain radio button in the first group is selected. I have gotten the radio button groups to display, but the are not saving to the database. I have used the hook_field_info and hook_field_schema functions but I'm not sure I'm implementing them correctly. Any insights would be greatly appreciated.
//Radio Button Group 1
$form['type1'] = array(
'#title' => t('Type 1'),
'#required' => true,
'#type' => 'radios',
'#options' => array(
'api_type_resource' => t('Description 1)'),
'api_type_experience' => t('Description 2)'),
'api_type_utility' => t('Description 3)'),
'api_type_unknown' => t('Unknown'),),
'#default_value' => empty($form['nid']['#value']) ? 'unknown_api_type' : 'unknown_api_type',
'#weight' => 3,
);
//Radio Button Group 2
$form['type2'] = array(
'#title' => t('Type 2'),
'#required' => true,
'#type' => 'radios',
'#options' => array(
'doa_owner' => t('Description 1'),
'doa_permission' => t('Description 2'),
'doa_not_engaged' => t('Description 3'),
'doa_unknown' => t('Unknown'),
),
'#default_value' => empty($form['nid']['#value']) ? 'doa_unknown' : 'doa_unknown',
'#states' => array(
'visible' => array(
'input[name="api_type"]' => array('value' => 'api_type_resource'))),
'#weight' => 4,
);
function module_general_field_info() {
return array(
'type1' => array(
'label' => t('API Type'),
'description' => 'some description',
),
'type2' => array(
'label' => t('Data Owner Authorization'),
'description' => 'some description',
),
);
}
/**
* Implements hook_field_schema().
userID1 - Enhancement 60
*/
function module_general_field_schema($field)
{
$columns = array(
'type1' => array(
'type' => 'varchar',
'not null' => TRUE,
),
'type2' => array(
'type' => 'varchar',
'not null' => TRUE,
),
);
return array('columns' => $columns);
}
When I inspect the html elements radio button options I'm not getting an identifier.
An element created in drupal looks like this:
<label class="option" for="field-und-96">Field Label</label>
The custom element looks like this:
<code><label class="option" for="field">My Field Label</label>