function views_form_views_form

Callback for the main step of a Views form. Invoked by views_form().

4 string references to 'views_form_views_form'
BulkForm::views_form_submit in drupal/core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php
Implements \Drupal\system\Plugin\views\field\BulkFormBase::views_form_submit().
BulkFormBase::views_form_submit in drupal/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php
Submit handler for the bulk form.
NodeBulkForm::views_form_submit in drupal/core/modules/node/lib/Drupal/node/Plugin/views/field/NodeBulkForm.php
Submit handler for the bulk form.
views_form in drupal/core/modules/views/views.module
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…

File

drupal/core/modules/views/views.module, line 1231
Primarily Drupal hooks and global API functions to manipulate views.

Code

function views_form_views_form($form, &$form_state, ViewExecutable $view, $output) {
  $form['#prefix'] = '<div class="views-form">';
  $form['#suffix'] = '</div>';
  $form['#theme'] = 'views_form_views_form';
  $form['#validate'][] = 'views_form_views_form_validate';
  $form['#submit'][] = 'views_form_views_form_submit';

  // Add the output markup to the form array so that it's included when the form
  // array is passed to the theme function.
  $form['output'] = array(
    '#type' => 'markup',
    '#markup' => $output,
    // This way any additional form elements will go before the view
    // (below the exposed widgets).
    '#weight' => 50,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  $substitutions = array();
  foreach ($view->field as $field_name => $field) {
    $form_element_name = $field_name;
    if (method_exists($field, 'form_element_name')) {
      $form_element_name = $field
        ->form_element_name();
    }
    $method_form_element_row_id_exists = FALSE;
    if (method_exists($field, 'form_element_row_id')) {
      $method_form_element_row_id_exists = TRUE;
    }

    // If the field provides a views form, allow it to modify the $form array.
    $has_form = FALSE;
    if (property_exists($field, 'views_form_callback')) {
      $callback = $field->views_form_callback;
      $callback($view, $field, $form, $form_state);
      $has_form = TRUE;
    }
    elseif (method_exists($field, 'views_form')) {
      $field
        ->views_form($form, $form_state);
      $has_form = TRUE;
    }

    // Build the substitutions array for use in the theme function.
    if ($has_form) {
      foreach ($view->result as $row_id => $row) {
        if ($method_form_element_row_id_exists) {
          $form_element_row_id = $field
            ->form_element_row_id($row_id);
        }
        else {
          $form_element_row_id = $row_id;
        }
        $substitutions[] = array(
          'placeholder' => '<!--form-item-' . $form_element_name . '--' . $form_element_row_id . '-->',
          'field_name' => $form_element_name,
          'row_id' => $form_element_row_id,
        );
      }
    }
  }

  // Give the area handlers a chance to extend the form.
  $area_handlers = array_merge(array_values($view->header), array_values($view->footer));
  $empty = empty($view->result);
  foreach ($area_handlers as $area) {
    if (method_exists($area, 'views_form') && !$area
      ->views_form_empty($empty)) {
      $area
        ->views_form($form, $form_state);
    }
  }
  $form['#substitutions'] = array(
    '#type' => 'value',
    '#value' => $substitutions,
  );
  return $form;
}