function uuidreference_form_alter in UUID reference field 7
Implements hook_form_FORM_ID_alter().
Alter the field_ui_settings_form to add in the correct bundle options via AJAX. This cannot be done in uuidreference_field_settings_form() as we don't have access to the whole form or form_state. We also have to account for the field settings form, and field settings edit form.
File
- ./
uuidreference.module, line 143
Code
function uuidreference_form_alter(&$form, &$form_state, $form_id) {
$entity_info = entity_get_info();
if ($form_id == 'field_ui_field_settings_form') {
if ($form['field']['module']['#value'] == 'uuidreference') {
if (!empty($form_state['input']['field']['settings']['target_type'])) {
$target_type = $form_state['input']['field']['settings']['target_type'];
}
else {
$target_type = $form['field']['settings']['target_type']['#default_value'];
}
_uuidreference_add_target_bundle_elements($form['field'], $form_state, $target_type, field_info_field($form['field']['field_name']['#value']), $entity_info);
}
}
if ($form_id == 'field_ui_field_edit_form') {
if ($form['#field']['module'] == 'uuidreference') {
if (!empty($form_state['input']['field']['settings']['target_type'])) {
$target_type = $form_state['input']['field']['settings']['target_type'];
}
else {
$target_type = $form['#field']['settings']['target_type'];
}
_uuidreference_add_target_bundle_elements($form['field']['settings'], $form_state, $target_type, $form['#field'], $entity_info);
}
}
}