You are here

public function PhotosDirectoryImportForm::validateForm in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 src/Form/PhotosDirectoryImportForm.php \Drupal\photos\Form\PhotosDirectoryImportForm::validateForm()
  2. 6.0.x src/Form/PhotosDirectoryImportForm.php \Drupal\photos\Form\PhotosDirectoryImportForm::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/PhotosDirectoryImportForm.php, line 177

Class

PhotosDirectoryImportForm
Defines a form to upload photos to this site.

Namespace

Drupal\photos\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $directory = $form_state
    ->getValue('directory');

  // Check if directory exists.
  if (!empty($directory) && !is_dir($directory)) {
    return $form_state
      ->setErrorByName('directory', $this
      ->t('Could not find directory. Please check the path.'));
  }
}