You are here

public function MiconForm::validateForm in Micon 8

Same name and namespace in other branches
  1. 2.x src/Form/MiconForm.php \Drupal\micon\Form\MiconForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

File

src/Form/MiconForm.php, line 148

Class

MiconForm
Class MiconForm.

Namespace

Drupal\micon\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  parent::validateForm($form, $form_state);
  $this->file = file_save_upload('file', $form['file']['#upload_validators'], FALSE, 0);

  // Ensure we have the file uploaded.
  if (!$this->file && $this->entity
    ->isNew()) {
    $form_state
      ->setErrorByName('file', $this
      ->t('File to import not found.'));
  }
}