1 views_ui.admin.inc views_ui_preview_form($form, &$form_state, $view, $display_id = 'default')

Provide the preview formulas and the preview output, too.

File

core/modules/views_ui/views_ui.admin.inc, line 1197
Admin page callbacks for the Views UI module.

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' => config_get('views_ui.settings', 'always_live_preview'),
  );

  // 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',
  );

  // Add the preview button
  $form['button'] = array(
    '#type' => 'submit',
    '#value' => t('Update preview'),
    '#attributes' => array('class' => array('arguments-preview')),
    '#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;
}