Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
Overrides WidgetInterface::formElement
public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
$field = $this->field;
$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' => $this
->getSetting('autocomplete_path') . '/' . $field['field_name'],
'#size' => $this
->getSetting('size'),
'#placeholder' => $this
->getSetting('placeholder'),
'#maxlength' => 1024,
'#element_validate' => array(
'taxonomy_autocomplete_validate',
),
);
return $element;
}