You are here

public function SettingsForm::validateForm in Responsive and off-canvas menu 4.3.x

Same name and namespace in other branches
  1. 8.3 src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::validateForm()
  2. 8.2 src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::validateForm()
  3. 4.4.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::validateForm()
  4. 4.0.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::validateForm()
  5. 4.1.x src/Form/SettingsForm.php \Drupal\responsive_menu\Form\SettingsForm::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/SettingsForm.php, line 310

Class

SettingsForm
Form builder for the responsive_menu admin settings page.

Namespace

Drupal\responsive_menu\Form

Code

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

  // Ensure there are breakpoints configured.
  $values = $form_state
    ->getValues();
  if ($values['use_breakpoint'] && empty($values['horizontal_breakpoint'])) {
    $breakpoint_message = Link::fromTextAndUrl('breakpoint file', Url::fromUri('https://www.drupal.org/node/1803874'))
      ->toRenderable();
    $form_state
      ->setErrorByName('horizontal_breakpoint', $this
      ->t("You have chosen to use a breakpoint but you have not selected one. This may happen if your @breakpoint is not properly set up.", [
      '@breakpoint' => render($breakpoint_message),
    ]));
  }
}