You are here

public static function FileUpload::ajax in Lightning Media 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/Widget/FileUpload.php \Drupal\lightning_media\Plugin\EntityBrowser\Widget\FileUpload::ajax()

AJAX callback. Returns the rebuilt inline entity form.

Parameters

array $form: The complete form.

FormStateInterface $form_state: The current form state.

Return value

\Drupal\Core\Ajax\AjaxResponse The AJAX response.

Overrides EntityFormProxy::ajax

File

src/Plugin/EntityBrowser/Widget/FileUpload.php, line 146

Class

FileUpload
An Entity Browser widget for creating media entities from uploaded files.

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

public static function ajax(array &$form, FormStateInterface $form_state) {
  $el = AjaxUpload::el($form, $form_state);
  $wrapper = '#' . $el['#ajax']['wrapper'];
  return parent::ajax($form, $form_state)
    ->addCommand(new ReplaceCommand($wrapper, $el))
    ->addCommand(new PrependCommand($wrapper, [
    '#type' => 'status_messages',
  ]));
}