public function ImportActivityForm::validateForm in Opigno module 8
Same name and namespace in other branches
- 3.x src/Form/ImportActivityForm.php \Drupal\opigno_module\Form\ImportActivityForm::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/ ImportActivityForm.php, line 62 
Class
- ImportActivityForm
- Import Activity form.
Namespace
Drupal\opigno_module\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
  // Validation is optional.
  if (empty($_FILES['files']['name']['activity_opi'])) {
    // Only need to validate if the field actually has a file.
    $form_state
      ->setError($form['activity_opi'], $this
      ->t("The file was not uploaded."));
  }
}