You are here

function redhen_org_set_primary_form in RedHen CRM 7

Form callback: confirmation form for changing the primary contact.

See also

confirm_form()

1 string reference to 'redhen_org_set_primary_form'
redhen_org_menu in modules/redhen_org/redhen_org.module
Implements hook_menu().

File

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

Code

function redhen_org_set_primary_form($form, &$form_state, $org, $contact) {
  $form_state['redhen_org'] = $org;
  $form_state['redhen_contact'] = $contact;
  $form['#submit'][] = 'redhen_org_set_primary_form_submit';
  $existing = '';
  $wrapper = entity_metadata_wrapper('redhen_org', $org);
  $primary_contact = $wrapper->primary_contact
    ->value();
  if ($primary_contact) {
    $primary_contact_wrapper = entity_metadata_wrapper('redhen_contact', $primary_contact);
    $contact_name = $primary_contact_wrapper->full_name
      ->value();
    $existing = '<p>' . t('%old_primary will no longer be the primary contact.', array(
      '%old_primary' => $contact_name,
    )) . '</p>';
  }
  $contact_wrapper = entity_metadata_wrapper('redhen_contact', $contact);
  $form = confirm_form($form, t('Are you sure you want to change the primary contact for %org to %name?', array(
    '%org' => $org->label,
    '%name' => $contact_wrapper->full_name
      ->value(),
  )), entity_uri('redhen_org', $org), $existing, t('Change'), t('Cancel'), 'confirm');
  return $form;
}