function views_ui_preview_form

3.x admin.inc views_ui_preview_form($form, &$form_state, $view, $display_id = 'default')
2.x admin.inc views_ui_preview_form(&$form_state)

Provide the preview formulas and the preview output, too.

1 string reference to 'views_ui_preview_form'

File

includes/admin.inc, line 1174
Provides the Views' administrative interface.

Code

function views_ui_preview_form($form, &$form_state, $view, $display_id = 'default') {
  $form_state['no_cache'] = TRUE;
  $form_state['view'] = $view;

  $form['#attributes'] = array('class' => array('clearfix',));

  // Add a checkbox controlling whether or not this display auto-previews.
  $form['live_preview'] = array(
    '#type' => 'checkbox',
    '#id' => 'edit-displays-live-preview',
    '#title' => t('Auto preview'),
    '#default_value' => variable_get('views_ui_always_live_preview', TRUE),
  );

  // Add the arguments textfield
  $form['view_args'] = array(
    '#type' => 'textfield',
    '#title' => t('Preview with contextual filters:'),
    '#description' => t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')),
    '#id' => 'preview-args',
    //      '#attributes' => array('class' => array('ctools-auto-submit')),
  );

  // Add the preview button
  $form['button'] = array(
    '#type' => 'submit',
    '#value' => t('Update preview'),
    '#attributes' => array('class' => array('arguments-preview', 'ctools-auto-submit-click')),
    '#pre_render' => array('ctools_dependent_pre_render'),
    '#prefix' => '<div id="preview-submit-wrapper">',
    '#suffix' => '</div>',
    '#id' => 'preview-submit',
    '#submit' => array('views_ui_edit_form_submit_preview'),
    '#ajax' => array(
      'path' => 'admin/structure/views/view/' . $view->name . '/preview/' . $display_id . '/ajax',
      'wrapper' => 'views-preview-wrapper',
      'event' => 'click',
      'progress' => array('type' => 'throbber'),
      'method' => 'replace',
    ),
    // Make ENTER in arguments textfield (and other controls) submit the form
    // as this button, not the Save button.
    // @todo This only works for JS users. To make this work for nojs users,
    //   we may need to split Preview into a separate form.
    '#process' => array_merge(array('views_ui_default_button'), element_info_property('submit', '#process', array())),
  );
  $form['#action'] = url('admin/structure/views/view/' . $view->name . '/preview/' . $display_id);

  return $form;
}