You are here

public function ImportModuleForm::validateForm in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Form/ImportModuleForm.php \Drupal\opigno_module\Form\ImportModuleForm::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/ImportModuleForm.php, line 59

Class

ImportModuleForm
Import Module form.

Namespace

Drupal\opigno_module\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {

  // Validation is optional.
  if (empty($_FILES['files']['name']['module_opi'])) {

    // Only need to validate if the field actually has a file.
    $form_state
      ->setError($form['module_opi'], $this
      ->t("The file was not uploaded."));
  }
}