function views_ui_reorder_displays_form

Same name in other branches
  1. 7.x-3.x includes/admin.inc \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_reorder_view in includes/admin.inc
Page callback to display analysis information on a view.

File

includes/admin.inc, line 2114

Code

function views_ui_reorder_displays_form(&$form_state) {
    $view =& $form_state['view'];
    $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(
                '#value' => $display->display_title,
            ),
            'weight' => array(
                '#type' => 'weight',
                '#value' => $display->position,
                '#delta' => $last_display->position,
            ),
            '#tree' => TRUE,
            '#display' => $display,
            'removed' => array(
                '#type' => 'checkbox',
                '#id' => 'display-removed-' . $display->id,
                '#attributes' => array(
                    'class' => '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/build/views/nojs/reorder-display/' . $view->name);
    views_ui_standard_form_buttons($form, $form_state, 'views_ui_reorder_displays_form');
    return $form;
}