function shortcut_set_switch_validate

Validation handler for shortcut_set_switch().

File

drupal/core/modules/shortcut/shortcut.admin.inc, line 115
Administrative page callbacks for the shortcut module.

Code

function shortcut_set_switch_validate($form, &$form_state) {
  if ($form_state['values']['set'] == 'new') {

    // Check to prevent creating a shortcut set with an empty title.
    if (trim($form_state['values']['label']) == '') {
      form_set_error('new', t('The new set label is required.'));
    }

    // Check to prevent a duplicate title.
    if (shortcut_set_title_exists($form_state['values']['label'])) {
      form_set_error('label', t('The shortcut set %name already exists. Choose another name.', array(
        '%name' => $form_state['values']['label'],
      )));
    }
  }
}