function UriWidget::formElement

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

Overrides WidgetInterface::formElement

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php, line 70

Class

UriWidget
Plugin implementation of the 'uri' 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' => 'url',
        '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
        '#size' => $this->getSetting('size'),
        '#placeholder' => $this->getSetting('placeholder'),
        '#maxlength' => $this->getFieldSetting('max_length'),
    ];
    return $element;
}

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