You are here

public static function InteractiveUpload::remove in Lightning Media 8

Same name and namespace in other branches
  1. 8.4 src/Element/InteractiveUpload.php \Drupal\lightning_media\Element\InteractiveUpload::remove()
  2. 8.2 src/Element/InteractiveUpload.php \Drupal\lightning_media\Element\InteractiveUpload::remove()
  3. 8.3 src/Element/InteractiveUpload.php \Drupal\lightning_media\Element\InteractiveUpload::remove()

Handles form submission when the Remove button is clicked.

Parameters

array $form: The complete form.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

File

src/Element/InteractiveUpload.php, line 131

Class

InteractiveUpload
A form element for uploading or deleting files interactively.

Namespace

Drupal\lightning_media\Element

Code

public static function remove(array &$form, FormStateInterface $form_state) {
  $el = static::el($form, $form_state);
  Upload::delete($el['fid']);
  $form_state
    ->setValueForElement($el['fid'], NULL);
  NestedArray::setValue($form_state
    ->getUserInput(), $el['fid']['#parents'], NULL);
  $form_state
    ->setRebuild();
}