You are here

public function Upload::submit in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/Widget/Upload.php \Drupal\entity_browser\Plugin\EntityBrowser\Widget\Upload::submit()

Submits form.

Parameters

array $element: Widget part of the form.

array $form: Form.

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

Overrides WidgetBase::submit

File

src/Plugin/EntityBrowser/Widget/Upload.php, line 133

Class

Upload
Adds an upload field browser's widget.

Namespace

Drupal\entity_browser\Plugin\EntityBrowser\Widget

Code

public function submit(array &$element, array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getTriggeringElement()['#eb_widget_main_submit'])) {
    $files = $this
      ->prepareEntities($form, $form_state);
    array_walk($files, function (FileInterface $file) {
      $file
        ->setPermanent();
      $file
        ->save();
    });
    $this
      ->selectEntities($files, $form_state);
    $this
      ->clearFormValues($element, $form_state);
  }
}