You are here

function _multiform_get_form in Multiple forms 7.2

Same name and namespace in other branches
  1. 7 multiform.module \_multiform_get_form()

Change $element['#name'] to get proper $_POST structure on multiform submission.

1 call to _multiform_get_form()
multiform_form_after_build in ./multiform.module
Multiform subform #after_build.

File

./multiform.module, line 198

Code

function _multiform_get_form(&$element, $form_id) {

  // Recurse.
  foreach (element_children($element) as $key) {
    _multiform_get_form($element[$key], $form_id);
  }

  // By only changing $element['#name'] form API is not affected but the
  // browser will put the element values into _POST where multiform_get_form
  // expects them.
  if (isset($element['#name'])) {

    // If the name was op then we want multiform[$form_id][op]. If it was
    // foo[bar] then we want multiform[$form_id][foo][bar].
    $element['#name'] = "multiform[{$form_id}]" . preg_replace('/^[^[]+/', '[\\0]', $element['#name']);
  }
}