function taxonomy_field_widget_form

Implements hook_field_widget_form().

File

modules/taxonomy/taxonomy.module, line 1736

Code

function taxonomy_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
    $tags = array();
    foreach ($items as $item) {
        $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
    }
    $element += array(
        '#type' => 'textfield',
        '#default_value' => taxonomy_implode_tags($tags),
        '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $field['field_name'],
        '#size' => $instance['widget']['settings']['size'],
        '#maxlength' => 1024,
        '#element_validate' => array(
            'taxonomy_autocomplete_validate',
        ),
    );
    return $element;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.