You are here

public function EmbedCode::getForm in Lightning Media 8.2

Same name and namespace in other branches
  1. 8.4 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::getForm()
  2. 8 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::getForm()
  3. 8.3 src/Plugin/EntityBrowser/Widget/EmbedCode.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\EmbedCode::getForm()

Overrides EntityFormProxy::getForm

File

src/Plugin/EntityBrowser/Widget/EmbedCode.php, line 21

Class

EmbedCode
An Entity Browser widget for creating media entities from embed codes.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters) {
  $form = parent::getForm($original_form, $form_state, $additional_widget_parameters);
  $form['input'] = [
    '#type' => 'textarea',
    '#placeholder' => $this
      ->t('Enter a URL...'),
    '#attributes' => [
      'class' => [
        'keyup-change',
      ],
    ],
    '#ajax' => [
      'event' => 'change',
      'wrapper' => 'entity',
      'method' => 'html',
      'callback' => [
        static::class,
        'ajax',
      ],
    ],
  ];

  // Allow the form to be rebuilt without using AJAX.
  $form['update'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Update'),
    '#attributes' => [
      'class' => [
        'js-hide',
      ],
    ],
    '#submit' => [
      [
        static::class,
        'update',
      ],
    ],
  ];
  return $form;
}