You are here

function party_data_set_attach_form_submit in Party 7

Same name and namespace in other branches
  1. 8.2 party.module \party_data_set_attach_form_submit()

Submit attached entity forms

1 string reference to 'party_data_set_attach_form_submit'
party_data_set_attach_form in ./party.module
Attach attached entity forms to a form.

File

./party.module, line 1198
Provides a generic CRM party entity.

Code

function party_data_set_attach_form_submit(&$form, &$form_state) {

  // Collect which controllers we need to save.
  $controllers = array();
  foreach (element_children($form) as $form_key) {
    $element =& $form[$form_key];

    // Only act if we are confident this is an attached entity form element.
    if (empty($element['#data_set_name']) || !party_get_data_set_info($element['#data_set_name'])) {
      continue;
    }

    // Get the form callback.
    $callback = party_attached_entity_form_callback($element['#data_set_name']) . '_submit';

    // Execute the form callback.
    $return = $callback($element, $form_state, $element['#data_set'], $element['#delta'], $element['#data_set']
      ->getParty());
    $controllers[$element['#data_set_name']] = $element['#data_set'];
  }
  foreach ($controllers as $controller) {
    $controller
      ->save();
  }
}