You are here

public function TourBuilderCloneForm::validateForm in Tour Builder 8

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/TourBuilderCloneForm.php, line 82

Class

TourBuilderCloneForm
Form controller for the tour entity clone form.

Namespace

Drupal\tour_builder\Form

Code

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

  // Make sure new_name does not exists
  // Make sure module exists.
  $old_name = $form_state
    ->getValue('old_name');
  $new_name = $form_state
    ->getValue('new_name');
  if ($form_state
    ->isValueEmpty('new_name')) {
    $form_state
      ->setError($form['new_name'], $this
      ->t('The tour file name cannot be empty.'));
  }
  if ($old_name == $new_name) {
    $form_state
      ->setError($form['new_name'], $this
      ->t('You must change the new tour file name', [
      '%tip' => 'XXX',
    ]));
  }
}