function fe_taxonomy_machine_name_validate in Features Extra 6
Validate machine name.
1 string reference to 'fe_taxonomy_machine_name_validate'
- fe_taxonomy_form_alter in ./
fe_taxonomy.module - Implementation of hook_form_alter().
File
- ./
fe_taxonomy.module, line 251
Code
function fe_taxonomy_machine_name_validate($form, &$form_state) {
if (empty($form_state['values']['machine_name'])) {
return;
}
$table = 'fe_taxonomy_vocabulary';
if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['machine_name'])) {
form_set_error('machine_name', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
elseif (db_result(db_query("SELECT COUNT(*) FROM {{$table}} WHERE vid <> %d AND machine_name = '%s'", $form_state['values']['vid'], $form_state['values']['machine_name']))) {
form_set_error('machine_name', t('The machine-readable name has been taken. Please pick another one.'));
}
}