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) {
$main_widget = $element + array(
'#type' => 'textfield',
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
'#size' => $this
->getSetting('size'),
'#placeholder' => $this
->getSetting('placeholder'),
'#maxlength' => $this->field['settings']['max_length'],
'#attributes' => array(
'class' => array(
'text-full',
),
),
);
if ($this->instance['settings']['text_processing']) {
$element = $main_widget;
$element['#type'] = 'text_format';
$element['#format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL;
$element['#base_type'] = $main_widget['#type'];
}
else {
$element['value'] = $main_widget;
}
return $element;
}