function _form_builder_positions_prepare in Form Builder 6
Recursive helper for form_builder_positions(). Add weight fields.
1 call to _form_builder_positions_prepare()
- form_builder_positions in includes/
form_builder.admin.inc - Form containing all the current weights and parents of elements.
File
- includes/
form_builder.admin.inc, line 258 - form_builder.admin.inc Administrative interface for editing forms.
Code
function _form_builder_positions_prepare(&$form, $form_cache, $parent_id = FORM_BUILDER_ROOT) {
foreach (element_children($form_cache) as $key) {
// Keep record of the current parent ID.
$previous_parent_id = $parent_id;
if (isset($form_cache[$key]['#form_builder']['element_id'])) {
// Set the parent ID for this element.
$form_cache[$key]['#form_builder']['parent_id'] = $parent_id;
$element_id = $form_cache[$key]['#form_builder']['element_id'];
$parent_id = $element_id;
$form[$element_id]['weight'] = array(
'#type' => 'hidden',
'#default_value' => isset($form_cache[$key]['#weight']) ? $form_cache[$key]['#weight'] : 0,
'#attributes' => array(
'class' => 'form-builder-weight form-builder-element-' . $element_id,
),
);
$form[$element_id]['parent'] = array(
'#type' => 'hidden',
'#default_value' => $form_cache[$key]['#form_builder']['parent_id'],
'#attributes' => array(
'class' => 'form-builder-parent form-builder-element-' . $element_id,
),
);
}
_form_builder_positions_prepare($form, $form_cache[$key], $parent_id);
$parent_id = $previous_parent_id;
}
}