function SwitchShortcutSet::validateForm

Same name in other branches
  1. 9 core/modules/shortcut/src/Form/SwitchShortcutSet.php \Drupal\shortcut\Form\SwitchShortcutSet::validateForm()
  2. 8.9.x core/modules/shortcut/src/Form/SwitchShortcutSet.php \Drupal\shortcut\Form\SwitchShortcutSet::validateForm()
  3. 11.x core/modules/shortcut/src/Form/SwitchShortcutSet.php \Drupal\shortcut\Form\SwitchShortcutSet::validateForm()

Overrides FormBase::validateForm

File

core/modules/shortcut/src/Form/SwitchShortcutSet.php, line 160

Class

SwitchShortcutSet
Builds the shortcut set switch form.

Namespace

Drupal\shortcut\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
    if ($form_state->getValue('set') == 'new') {
        // Check to prevent creating a shortcut set with an empty title.
        if (trim($form_state->getValue('label')) == '') {
            $form_state->setErrorByName('label', $this->t('The new set label is required.'));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.