You are here

function form_builder_positions_submit in Form Builder 6

Same name and namespace in other branches
  1. 7.2 includes/form_builder.admin.inc \form_builder_positions_submit()
  2. 7 includes/form_builder.admin.inc \form_builder_positions_submit()

Submit handler for the form_builder_positions form.

File

includes/form_builder.admin.inc, line 289
form_builder.admin.inc Administrative interface for editing forms.

Code

function form_builder_positions_submit(&$form, &$form_state) {
  module_load_include('inc', 'form_builder', 'includes/form_builder.api');
  module_load_include('inc', 'form_builder', 'includes/form_builder.cache');
  $form_type = $form['#form_builder']['form_type'];
  $form_id = $form['#form_builder']['form_id'];
  $form_cache = $form['#form_builder']['form'];
  foreach (element_children($form) as $element_id) {

    // Skip items without weight value (like the form token, build_id, etc).
    if (!isset($form[$element_id]['weight'])) {
      continue;
    }

    // Check for changed weights or parents.
    $element = form_builder_get_element($form_cache, $element_id);
    $element['#weight'] = $form_state['values'][$element_id]['weight'];
    $element['#form_builder']['parent_id'] = $form_state['values'][$element_id]['parent'];
    form_builder_set_element($form_cache, $element);
  }

  // Save all the changes made.
  form_builder_cache_save($form_type, $form_id, $form_cache);

  // Don't redirect, which will cause an unnecessary HTTP request.
  $form_state['redirect'] = FALSE;
}