Version 1
[yaffs-website] / web / modules / contrib / video_embed_field / src / Plugin / Field / FieldWidget / VideoTextfield.php
diff --git a/web/modules/contrib/video_embed_field/src/Plugin/Field/FieldWidget/VideoTextfield.php b/web/modules/contrib/video_embed_field/src/Plugin/Field/FieldWidget/VideoTextfield.php
new file mode 100644 (file)
index 0000000..5a5d84c
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\video_embed_field\Plugin\Field\FieldWidget;
+
+use Drupal\Core\Field\FieldItemListInterface;
+use Drupal\Core\Field\WidgetBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * A widget to input video URLs.
+ *
+ * @FieldWidget(
+ *   id = "video_embed_field_textfield",
+ *   label = @Translation("Video Textfield"),
+ *   field_types = {
+ *     "video_embed_field"
+ *   },
+ * )
+ */
+class VideoTextfield extends WidgetBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
+    $element['value'] = $element + [
+      '#type' => 'textfield',
+      '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
+      '#size' => 60,
+      '#maxlength' => $this->getFieldSetting('max_length'),
+      '#attributes' => ['class' => ['js-text-full', 'text-full']],
+      '#allowed_providers' => $this->getFieldSetting('allowed_providers'),
+    ];
+    return $element;
+  }
+
+}