function EmailDefaultWidget::formElement

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\EmailDefaultWidget::formElement()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\EmailDefaultWidget::formElement()
  3. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php \Drupal\Core\Field\Plugin\Field\FieldWidget\EmailDefaultWidget::formElement()

Overrides WidgetInterface::formElement

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php, line 73

Class

EmailDefaultWidget
Plugin implementation of the 'email_default' widget.

Namespace

Drupal\Core\Field\Plugin\Field\FieldWidget

Code

public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $element['value'] = $element + [
        '#type' => 'email',
        '#default_value' => $items[$delta]->value ?? NULL,
        '#placeholder' => $this->getSetting('placeholder'),
        '#size' => $this->getSetting('size'),
        '#maxlength' => Email::EMAIL_MAX_LENGTH,
    ];
    return $element;
}

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