You are here

function taxonomy_access_autocomplete_default_value in Taxonomy Access Control 7

Default value re-generation for autocomplete fields.

Parameters

array $items: An array of values from form build info, filtered by create grants.

Return value

string Field default value.

See also

taxonomy_field_widget_form()

Related topics

1 call to taxonomy_access_autocomplete_default_value()
_taxonomy_access_autocomplete_alter in ./taxonomy_access.create.inc
Implements the create grant for autocomplete fields.

File

./taxonomy_access.create.inc, line 581
Implements the Add Tag (create) grant on editing forms.

Code

function taxonomy_access_autocomplete_default_value(array $items) {

  // Preserve the original state of the list flag.
  $flag_state = taxonomy_access_list_enabled();

  // Enforce that list grants do not filter the options list.
  taxonomy_access_disable_list();

  // Assemble list of tags.
  $tags = array();
  foreach ($items as $item) {
    $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
  }

  // Assemble the default value using taxonomy.module.
  $tags = taxonomy_implode_tags($tags);

  // Restore list flag to previous state.
  if ($flag_state) {
    taxonomy_access_enable_list();
  }
  return $tags;
}