function crm_core_contact_ui_type_delete_confirm_validate in CRM Core 7
Form validation callback
File
- modules/
crm_core_contact_ui/ crm_core_contact_ui.admin.inc, line 154 - Interface elements for adding, editing, and otherwise working with contact types.
Code
function crm_core_contact_ui_type_delete_confirm_validate($form, &$form_state) {
$crm_core_contact_type = $form_state['contact_type'];
// check one more time to see if the contact type can be deleted
$error = NULL;
if ((bool) $crm_core_contact_type->locked) {
$error = t('The contact type is locked');
}
$count = db_query("SELECT count(*) FROM {crm_core_contact} WHERE `type` = :type", array(
':type' => $crm_core_contact_type->type,
))
->fetchField();
if ($count > 0) {
$error = t('Contacts of this type exists');
}
if (isset($error)) {
form_set_error('message', t('Error: you cannot delete this contact type because @msg', array(
'@msg' => $error,
)));
}
}