You are here

function _workbench_access_taxonomy_remove_option in Workbench Access 7

Helper function to remove the option from Field UI forms.

3 calls to _workbench_access_taxonomy_remove_option()
taxonomy_workbench_access_field_form_alter in modules/taxonomy.workbench_access.inc
Implements hook_workbench_access_FORM_ID_alter().
taxonomy_workbench_access_field_ui_field_edit_form_alter in modules/taxonomy.workbench_access.inc
Implements hook_workbench_access_FORM_ID_alter().
taxonomy_workbench_access_field_ui_field_settings_form_alter in modules/taxonomy.workbench_access.inc
Implements hook_workbench_access_FORM_ID_alter().

File

modules/taxonomy.workbench_access.inc, line 127
Taxonomy integration for Workbench Access.

Code

function _workbench_access_taxonomy_remove_option(&$form) {
  if (!variable_get('workbench_access_custom_form', 1)) {
    return;
  }

  // The element we want is nested very deeply in the form.
  if (!isset($form['field']['settings']['allowed_values'])) {
    return;
  }

  // Cannot trust positional arrays to find the options.
  foreach ($form['field']['settings']['allowed_values'] as $key => $value) {
    if (is_array($value) && isset($value['vocabulary']) && isset($form['field']['settings']['allowed_values'][$key]['vocabulary']['#options']['workbench_access'])) {
      unset($form['field']['settings']['allowed_values'][$key]['vocabulary']['#options']['workbench_access']);
    }
  }
}