function token_custom_edit_form_validate in Custom Tokens 6
Same name and namespace in other branches
- 5 token_custom.module \token_custom_edit_form_validate()
File
- ./
token_custom.module, line 182 - The Token Custom module.
Code
function token_custom_edit_form_validate($form, &$form_state) {
if (substr($form_state['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_state['values']['token_custom_id'];
if ($form_state['values']['token_custom_tkid']) {
$where = ' AND tkid != %d ';
$args[] = $form_state['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'));
}
}