function pet_validate_name in Previewable email templates 6
Validate the PET name.
1 call to pet_validate_name()
- pet_add_form_validate in ./
pet.admin.inc - Validate the PET. Could do better callback and token type validation
File
- ./
pet.admin.inc, line 190 - Contains administrative pages for creating, editing, and deleting previewable email templates (PETs).
Code
function pet_validate_name($name, $form_state) {
// Ensure a safe machine name.
if (!preg_match('/^[a-z_][a-z0-9_]*$/', $name)) {
form_set_error('name', t('The template name may only contain lowercase letters, underscores, and numbers.'));
}
// Ensure the machine name is unique
if (empty($form_state['values']['pid'])) {
$pet = pet_load($name);
if ($pet->name == $name) {
form_set_error('name', t('Template names must be unique. This name is already in use.'));
}
}
}