You are here

function multiform_delayed_submit_execute in Multiple forms 7.2

Execute subform handlers and perform other tasks.

Here we pass variable by reference instead of returning array of values.

1 call to multiform_delayed_submit_execute()
multiform_get_form in ./multiform.module
Returns a form containing a number of other forms.

File

./multiform.inc, line 109

Code

function multiform_delayed_submit_execute(&$multiform, &$subform_form, &$subform_state, $subform_id) {
  $subform_form = $multiform['#subforms'][$subform_id]['form'];
  $subform_state = $multiform['#subforms'][$subform_id]['form_state'];
  $unprocessed_subform = $multiform['#subforms'][$subform_id]['unprocessed_form'];
  multiform_drupal_process_form_finish($subform_id, $subform_form, $subform_state, $unprocessed_subform);

  // Store data (submit results) for #before_execute and #after_execute hooks.
  // Data can be used/changed in #before_execute and #after_execute hooks.
  // Usually only $form_state is changed in submit handlers.
  // Also there is no trouble if form wasn't submitted. Data isn't used anywhere
  // else except those hooks.
  // Actually, these are needed only if multiform was submitted and validation
  // passed correctly.
  $multiform['#subforms'][$subform_id]['form'] = $subform_form;
  $multiform['#subforms'][$subform_id]['form_state'] = $subform_state;

  // Invoke #after_execute functions for each form after it is submitted.
  // Invoke only in case form was submitted and there are
  // no validation errors (see multiform_drupal_process_form_finish()).
  $subform_settings = $multiform['#subforms'][$subform_id]['#subform_settings'];
  if ($subform_state['executed'] == TRUE) {
    foreach ($subform_settings['#after_execute'] as $function) {
      $function($multiform, $subform_id);
    }
  }
}