You are here

function redhen_org_set_primary_form_submit in RedHen CRM 7

Submit callback for redhen_org_set_primary_form().

1 string reference to 'redhen_org_set_primary_form_submit'
redhen_org_set_primary_form in modules/redhen_org/includes/redhen_org.forms.inc
Form callback: confirmation form for changing the primary contact.

File

modules/redhen_org/includes/redhen_org.forms.inc, line 250
Forms for creating, editing, and deleting organizations.

Code

function redhen_org_set_primary_form_submit($form, &$form_state) {
  $org = $form_state['redhen_org'];
  $contact = $form_state['redhen_contact'];
  $org_name = $org->label;
  $contact_wrapper = entity_metadata_wrapper('redhen_contact', $contact);
  $contact_name = $contact_wrapper->full_name
    ->value();
  if ($org
    ->setPrimaryContact($contact)) {
    drupal_set_message(t('%contact_name has been set as the primary contact for %org_name.', array(
      '%contact_name' => $contact_name,
      '%org_name' => $org_name,
    )));
  }
  else {
    drupal_set_message(t('Unable to set %contact_name as the primary contact for %org_name.', array(
      '%contact_name' => $contact_name,
      '%org_name' => $org_name,
    )));
  }
  drupal_goto(drupal_get_destination());
}