You are here

function _redhen_contact_user_submission_apply in RedHen CRM 7

Same name and namespace in other branches
  1. 8 modules/redhen_contact/redhen_contact.module \_redhen_contact_user_submission_apply()

Helper function for handling Contact Form values submitted via User forms.

This happens when a RedHen Contact form is embedded in a User form via a form alter hook, then the from is submitted. Note that this function updates the $contact, but does not save the changes.

Parameters

array $form: Form array.

array $form_state: Form state array.

RedhenContact $contact: RedhenContact to update.

bool $limit_values: Whether to limit updated values to non-null fields.

Return value

string Status message.

2 calls to _redhen_contact_user_submission_apply()
redhen_contact_user_registration_submit in modules/redhen_contact/redhen_contact.module
Registration form RedHen contact submit handler.
redhen_contact_user_update_submit in modules/redhen_contact/redhen_contact.module
Update form RedHen contact submit handler.

File

modules/redhen_contact/redhen_contact.module, line 1368
Module file for RedHen contacts.

Code

function _redhen_contact_user_submission_apply($form, $form_state, RedhenContact $contact, $limit_values = FALSE) {
  if ($limit_values) {
    $value_state = redhen_contact_user_registration_form_state($form['redhen_contact']['form'], $form_state);
  }
  else {
    $value_state = $form_state;
  }

  // Save default parameters back into the $contact object.
  $contact->first_name = $form_state['values']['first_name'];
  $contact->middle_name = $form_state['values']['middle_name'];
  $contact->last_name = $form_state['values']['last_name'];

  // Notify field widgets using the limited state variable.
  field_attach_submit('redhen_contact', $contact, $form['redhen_contact']['form'], $value_state);
  return t('The contact was updated with the information provided.');
}