function TelephoneDefaultWidget::formElement

Same name in other branches
  1. 9 core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php \Drupal\telephone\Plugin\Field\FieldWidget\TelephoneDefaultWidget::formElement()
  2. 8.9.x core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php \Drupal\telephone\Plugin\Field\FieldWidget\TelephoneDefaultWidget::formElement()
  3. 11.x core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php \Drupal\telephone\Plugin\Field\FieldWidget\TelephoneDefaultWidget::formElement()

Overrides WidgetInterface::formElement

File

core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php, line 64

Class

TelephoneDefaultWidget
Plugin implementation of the 'telephone_default' widget.

Namespace

Drupal\telephone\Plugin\Field\FieldWidget

Code

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

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