You are here

function views_form in Views (for Drupal 7) 8.3

Same name and namespace in other branches
  1. 6.3 views.module \views_form()
  2. 7.3 views.module \views_form()

This is the entry function. Just gets the form for the current step. The form is always assumed to be multistep, even if it has only one step (the default 'views_form_views_form' step). That way it is actually possible for modules to have a multistep form if they need to.

4 string references to 'views_form'
views_forms in ./views.module
Implements hook_forms().
views_form_id in ./views.module
Returns a form ID for a Views form using the name and display of the View.
views_form_views_form in ./views.module
Callback for the main step of a Views form. Invoked by views_form().
views_view_has_form_elements in ./views.module
Returns TRUE if the passed-in view contains handlers with views form implementations, FALSE otherwise.

File

./views.module, line 1721
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_form($form, &$form_state, ViewExecutable $view, $output) {
  $form_state['step'] = isset($form_state['step']) ? $form_state['step'] : 'views_form_views_form';

  // Cache the built form to prevent it from being rebuilt prior to validation
  // and submission, which could lead to data being processed incorrectly,
  // because the views rows (and thus, the form elements as well) have changed
  // in the meantime.
  $form_state['cache'] = TRUE;
  $form = array();
  $query = drupal_get_query_parameters();
  $form['#action'] = url($view
    ->getUrl(), array(
    'query' => $query,
  ));

  // Tell the preprocessor whether it should hide the header, footer, pager...
  $form['show_view_elements'] = array(
    '#type' => 'value',
    '#value' => $form_state['step'] == 'views_form_views_form' ? TRUE : FALSE,
  );
  $form = $form_state['step']($form, $form_state, $view, $output);
  return $form;
}