function views_ui_reorder_displays_form

Form constructor callback to reorder displays on a view.

1 string reference to 'views_ui_reorder_displays_form'
views_ui_ajax_forms in includes/admin.inc
Various subforms for editing the pieces of a view.

File

includes/admin.inc, line 3186

Code

function views_ui_reorder_displays_form($form, &$form_state) {
    $view =& $form_state['view'];
    $display_id = $form_state['display_id'];
    $form['view'] = array(
        '#type' => 'value',
        '#value' => $view,
    );
    $form['#tree'] = TRUE;
    $last_display = end($view->display);
    foreach ($view->display as $display) {
        $form[$display->id] = array(
            'title' => array(
                '#markup' => check_plain($display->display_title),
            ),
            'weight' => array(
                '#type' => 'weight',
                '#value' => $display->position,
                '#delta' => $last_display->position,
                '#title' => t('Weight for @display', array(
                    '@display' => $display->display_title,
                )),
                '#title_display' => 'invisible',
            ),
            '#tree' => TRUE,
            '#display' => $display,
            'removed' => array(
                '#type' => 'checkbox',
                '#id' => 'display-removed-' . $display->id,
                '#attributes' => array(
                    'class' => array(
                        'views-remove-checkbox',
                    ),
                ),
                '#default_value' => isset($display->deleted),
            ),
        );
        if (isset($display->deleted) && $display->deleted) {
            $form[$display->id]['deleted'] = array(
                '#type' => 'value',
                '#value' => TRUE,
            );
        }
        if ($display->id === 'default') {
            unset($form[$display->id]['weight']);
            unset($form[$display->id]['removed']);
        }
    }
    $form['#title'] = t('Displays Reorder');
    $form['#section'] = 'reorder';
    // Add JavaScript settings that will be added via $.extend for tabledragging.
    $form['#js']['tableDrag']['reorder-displays']['weight'][0] = array(
        'target' => 'weight',
        'source' => NULL,
        'relationship' => 'sibling',
        'action' => 'order',
        'hidden' => TRUE,
        'limit' => 0,
    );
    $form['#action'] = url('admin/structure/views/nojs/reorder-displays/' . $view->name . '/' . $display_id);
    views_ui_standard_form_buttons($form, $form_state, 'views_ui_reorder_displays_form');
    return $form;
}