function crm_core_contact_type_form_submit in CRM Core 7
Form submit handler: save a contact type.
1 string reference to 'crm_core_contact_type_form_submit'
- crm_core_contact_type_form in modules/
crm_core_contact/ crm_core_contact.admin.inc - Form callback: create or edit a contact type.
File
- modules/
crm_core_contact/ crm_core_contact.admin.inc, line 153 - Pages for administrative settings in CRM Core Contact.
Code
function crm_core_contact_type_form_submit($form, &$form_state) {
$contact_type = $form_state['contact_type'];
$updated = !empty($contact_type->type);
// Saving primary fields selection.
$contact_type->primary_fields = $form_state['values']['contact_type']['primary_fields_container'];
unset($form_state['values']['contact_type']['primary_fields_container']);
foreach ($form_state['values']['contact_type'] as $key => $value) {
$contact_type->{$key} = $value;
}
// Write the contact type to the database.
$contact_type->is_new = !$updated;
crm_core_contact_type_save($contact_type);
// Redirect based on the button clicked.
$form_state['redirect'] = 'admin/structure/crm-core/contact-types/';
drupal_set_message(t('Contact type saved.'));
}