You are here

public function FileUpload::validate in Lightning Media 8.4

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

Overrides EntityFormProxy::validate

File

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

Class

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

Namespace

Drupal\lightning_media\Plugin\EntityBrowser\Widget

Code

public function validate(array &$form, FormStateInterface $form_state) {
  $fid = $this
    ->getCurrentValue($form_state);
  if ($fid) {
    parent::validate($form, $form_state);
    $media = $this
      ->getCurrentEntity($form_state);
    if ($media) {
      foreach ($this
        ->validateFile($media) as $error) {
        $form_state
          ->setError($form['widget']['input'], $error);
      }
    }
  }
}