You are here

function _form_repopulate in Module Builder 7.2

Same name and namespace in other branches
  1. 6.2 includes/module_builder.pages.inc \_form_repopulate()
  2. 7 includes/module_builder.pages.inc \_form_repopulate()

Repopulate form with user values.

File

includes/module_builder.pages.inc, line 218
Menu callback for main module builder page.

Code

function _form_repopulate($form, $form_state) {

  #dsm($form);

  #dsm(element_children($form));

  #dsm($form_state);
  foreach (element_children($form) as $key) {
    if (isset($form[$key]['#repopulate'])) {

      #dsm('repop: ');

      #dsm($key);

      #$form[$key]['#default_value'] = 'repop!'; // this obviously works

      #$form[$key]['#default_value'] = $form_state['values'][$key]; // arg! here we only have values from page 2!
      $form[$key]['#default_value'] = $form_state['storage']['input'][$key];

      // this obviously works
    }

    // recurse into children
    $form[$key] = _form_repopulate($form[$key], $form_state);
  }

  // each element_children
  return $form;
}