function StringTextfieldWidget::singleElementObject

Overrides WidgetBase::singleElementObject

2 calls to StringTextfieldWidget::singleElementObject()
OEmbedWidget::singleElementObject in core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php
Returns the form for a single field widget.
TextfieldWidget::singleElementObject in core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
Returns the form for a single field widget.
2 methods override StringTextfieldWidget::singleElementObject()
OEmbedWidget::singleElementObject in core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php
Returns the form for a single field widget.
TextfieldWidget::singleElementObject in core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php
Returns the form for a single field widget.

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php, line 72

Class

StringTextfieldWidget
Plugin implementation of the 'string_textfield' widget.

Namespace

Drupal\Core\Field\Plugin\Field\FieldWidget

Code

public function singleElementObject(FieldItemListInterface $items, $delta, Widget $widget, ElementInterface $form, FormStateInterface $form_state) : ElementInterface {
  $value = $widget->createChild('value', Textfield::class, copyProperties: TRUE);
  $value->default_value = $items[$delta]->value ?? NULL;
  $value->size = $this->getSetting('size');
  $value->placeholder = $this->getSetting('placeholder');
  $value->maxlength = $this->getFieldSetting('max_length');
  $value->attributes = [
    'class' => [
      'js-text-full',
      'text-full',
    ],
  ];
  return $widget;
}

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