public SwitchShortcutSet::validateForm(array &$form, FormStateInterface $form_state)
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
- core/modules/shortcut/src/Form/SwitchShortcutSet.php, line 157
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.'));
}
}
}
Please login to continue.