function taxonomy_access_field_widget_form_alter in Taxonomy Access Control 7
Implements hook_field_widget_form_alter().
See also
_taxonomy_access_options_alter()
File
- ./taxonomy_access.module, line 373 
- Allows administrators to specify access control for taxonomy categories.
Code
function taxonomy_access_field_widget_form_alter(&$element, &$form_state, $context) {
  // Only act on taxonomy fields.
  if ($context['field']['type'] != 'taxonomy_term_reference') {
    return;
  }
  // Only act on options widgets.
  $widget = $context['instance']['widget']['type'];
  if (!in_array($widget, array(
    'options_buttons',
    'options_select',
  ))) {
    return;
  }
  // Enforce that list grants do not filter our queries.
  taxonomy_access_disable_list();
  // Add create grant handling.
  module_load_include('inc', 'taxonomy_access', 'taxonomy_access.create');
  _taxonomy_access_options_alter($element, $form_state, $context);
  // Re-enable list grants.
  taxonomy_access_enable_list();
}