public function TestFieldWidget::formElement

Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().

Overrides WidgetInterface::formElement

File

drupal/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/field/widget/TestFieldWidget.php, line 49
Definition of Drupal\field_test\Plugin\field\widget\TestFieldWidget.

Class

TestFieldWidget
Plugin implementation of the 'test_field_widget' widget.

Namespace

Drupal\field_test\Plugin\field\widget

Code

public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
  $element += array(
    '#type' => 'textfield',
    '#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
  );
  return array(
    'value' => $element,
  );
}