3 namespace Drupal\video_embed_field\Plugin\Field\FieldWidget;
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\WidgetBase;
7 use Drupal\Core\Form\FormStateInterface;
10 * A widget to input video URLs.
13 * id = "video_embed_field_textfield",
14 * label = @Translation("Video Textfield"),
20 class VideoTextfield extends WidgetBase {
25 public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
26 $element['value'] = $element + [
27 '#type' => 'textfield',
28 '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
30 '#maxlength' => $this->getFieldSetting('max_length'),
31 '#attributes' => ['class' => ['js-text-full', 'text-full']],
32 '#allowed_providers' => $this->getFieldSetting('allowed_providers'),
33 '#theme' => 'input__video',