views_form_views_form

6 views.module views_form_views_form($form, &$form_state, $view, $output)
7 views.module views_form_views_form($form, &$form_state, $view, $output)

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

2 string references to 'views_form_views_form'

File

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

Code

function views_form_views_form($form, &$form_state, $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(
    '#value' => $output,
    // This way any additional form elements will go before the view
    // (below the exposed widgets). 
    '#weight' => 50,
  );

  $substitutions = array();
  foreach ($view->field as $field_name => $field) {
    $has_form = FALSE;
    // If the field provides a views form, allow it to modify the $form array.
    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) {
        $substitutions[] = array(
          'placeholder' => '<!--form-item-' . $field_name . '--' . $row_id . '-->', 
          'field_name' => $field_name, 
          'row_id' => $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,
  );
  $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('Save'), 
    '#weight' => 100,
  );

  return $form;
}
Login or register to post comments