2659b5b34f9e7bdd7829f2e1f2f81b70a9a74978
[yaffs-website] / web / modules / contrib / video_embed_field / src / Plugin / Field / FieldWidget / VideoTextfield.php
1 <?php
2
3 namespace Drupal\video_embed_field\Plugin\Field\FieldWidget;
4
5 use Drupal\Core\Field\FieldItemListInterface;
6 use Drupal\Core\Field\WidgetBase;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * A widget to input video URLs.
11  *
12  * @FieldWidget(
13  *   id = "video_embed_field_textfield",
14  *   label = @Translation("Video Textfield"),
15  *   field_types = {
16  *     "video_embed_field"
17  *   },
18  * )
19  */
20 class VideoTextfield extends WidgetBase {
21
22   /**
23    * {@inheritdoc}
24    */
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,
29       '#size' => 60,
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',
34     ];
35     return $element;
36   }
37
38 }