You are here

function token_custom_edit_form_validate in Custom Tokens 5

Same name and namespace in other branches
  1. 6 token_custom.module \token_custom_edit_form_validate()

File

./token_custom.module, line 181

Code

function token_custom_edit_form_validate($form_id, $form_values) {
  if (substr($form_values['token_custom_id'], 0, 13) != 'token_custom_') {
    form_set_error('token_custom_id', t('Token ID must start with <b><i>token_custom_</i></b>'));
  }
  $args = array();
  $args[] = $form_values['token_custom_id'];
  if ($form_values['token_custom_tkid']) {
    $where = ' AND tkid != %d ';
    $args[] = $form_values['token_custom_tkid'];
  }
  $tkid = db_result(db_query("SELECT tkid FROM {token_custom} WHERE id = '%s' {$where}", $args));
  if ($tkid) {
    form_set_error('token_custom_id', t('Token ID already exists and must be unique, please change it'));
  }
}