You are here

public function WebformAdminConfigExportersForm::validateForm in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Form/AdminConfig/WebformAdminConfigExportersForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigExportersForm::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/AdminConfig/WebformAdminConfigExportersForm.php, line 102

Class

WebformAdminConfigExportersForm
Configure webform admin settings for exporters.

Namespace

Drupal\webform\Form\AdminConfig

Code

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

  // Copied from: system_check_directory().
  $temp_directory = $form_state
    ->getValue('temp_directory');
  if (!is_dir($temp_directory) && !$this->fileSystem
    ->mkdir($temp_directory, NULL, TRUE)) {
    $form_state
      ->setErrorByName('temp_directory', $this
      ->t('The directory %directory does not exist and could not be created.', [
      '%directory' => $temp_directory,
    ]));
  }
  if (is_dir($temp_directory) && !is_writable($temp_directory) && !$this->fileSystem
    ->chmod($temp_directory)) {
    $form_state
      ->setErrorByName('temp_directory', $this
      ->t('The directory %directory exists but is not writable and could not be made writable.', [
      '%directory' => $temp_directory,
    ]));
  }
  parent::validateForm($form, $form_state);
}