You are here

function _nat_node_form_vocabularies_get in Node Auto Term [NAT] 7.2

Same name and namespace in other branches
  1. 7 nat.module \_nat_node_form_vocabularies_get()

Parse the node form and retrieve the taxonomy fields.

Parameters

Array $form: The form array.

Return value

Array $vocabularies An array containing any taxonomy reference fields in the form array along with their vocabulary IDs.

1 call to _nat_node_form_vocabularies_get()
nat_form_alter in ./nat.module
Implements hook_form_alter().

File

./nat.module, line 799
NAT - node auto term - is a helper module that automatically creates a term using the same title as a node.

Code

function _nat_node_form_vocabularies_get($form) {

  // Collate taxonomy reference fields by their vocabulary IDs.
  $instances = field_info_instances('node', $form['#node']->type);
  $vocabularies = array();
  foreach ($instances as $name => $instance) {
    if (isset($form[$name])) {
      $field = field_info_field($name);
      if ($field['type'] == 'taxonomy_term_reference') {
        $vocabulary = taxonomy_vocabulary_machine_name_load($field['settings']['allowed_values'][0]['vocabulary']);
        $vocabulary->form_fields[] = $name;
        $vocabularies[$vocabulary->vid] = $vocabulary;
      }
    }
  }
  return $vocabularies;
}