You are here

protected function BlockFieldWidget::formSingleElement in Block field 8

Generates the form element for a single copy of the widget.

Overrides WidgetBase::formSingleElement

File

src/Plugin/Field/FieldWidget/BlockFieldWidget.php, line 193

Class

BlockFieldWidget
Plugin implementation of the 'block_field' widget.

Namespace

Drupal\block_field\Plugin\Field\FieldWidget

Code

protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
  $element = parent::formSingleElement($items, $delta, $element, $form, $form_state);

  // For single element set the plugin id title and description to use the
  // field's title and description.
  $element['plugin_id']['#title'] = $element['#title'];
  $element['plugin_id']['#title_display'] = $element['#title_display'];
  $element['plugin_id']['#description'] = $element['#description'];
  return $element;
}