You are here

function form_builder_positions in Form Builder 7.2

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

Form containing all the current weights and parents of elements.

2 string references to 'form_builder_positions'
form_builder_interface in includes/form_builder.admin.inc
Main form building interface. Can be used as a menu callback.
_form_builder_add_element in includes/form_builder.admin.inc
Menu callback helper for adding or cloning a field.

File

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

Code

function form_builder_positions($form, &$form_state, $form_obj, $form_type, $form_id) {
  form_load_include($form_state, 'inc', 'form_builder', 'includes/form_builder.admin');
  $form = array(
    '#tree' => TRUE,
    '#form_builder' => array(
      'form_type' => $form_type,
      'form_id' => $form_id,
    ),
  );
  foreach ($form_obj
    ->getElementIds() as $element_id) {
    $element = $form_obj
      ->getElementArray($element_id);
    $form[$element_id]['weight'] = array(
      '#type' => 'hidden',
      '#default_value' => isset($element['#weight']) ? $element['#weight'] : 0,
      '#attributes' => array(
        'class' => array(
          'form-builder-weight form-builder-element-' . $element_id,
        ),
      ),
    );
    $form[$element_id]['parent'] = array(
      '#type' => 'hidden',
      '#default_value' => $element['#form_builder']['parent_id'],
      '#attributes' => array(
        'class' => array(
          'form-builder-parent form-builder-element-' . $element_id,
        ),
      ),
    );
  }

  // Drupal MUST have a button to register submissions.
  // Add a button even though the form is only submitted via AJAX.
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
    '#ajax' => array(
      'callback' => 'form_builder_positions_ajax',
      'wrapper' => 'form_builder_positions',
    ),
  );
  return $form;
}