You are here

public function ImportTrainingForm::validateForm in Opigno module 3.x

Same name and namespace in other branches
  1. 8 src/Form/ImportTrainingForm.php \Drupal\opigno_module\Form\ImportTrainingForm::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/ImportTrainingForm.php, line 111

Class

ImportTrainingForm
Import Course form.

Namespace

Drupal\opigno_module\Form

Code

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

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

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