function form_builder_positions_submit in Form Builder 7.2
Same name and namespace in other branches
- 6 includes/form_builder.admin.inc \form_builder_positions_submit()
- 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 309 - 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 = Loader::instance()
->fromCache($form_type, $form_id);
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 if element has not been deleted in
// the meanwhile.
if ($element = $form_cache
->getElementArray($element_id)) {
$element['#weight'] = $form_state['values'][$element_id]['weight'];
$element['#form_builder']['parent_id'] = $form_state['values'][$element_id]['parent'];
$form_cache
->setElementArray($element);
}
}
// Save all the changes made.
$form_cache
->save();
// Don't redirect, which will cause an unnecessary HTTP request.
$form_state['redirect'] = FALSE;
}