You are here

function views_field_view_handler_field_view::options_form in Views Field View 6

Same name and namespace in other branches
  1. 7 views_field_view_handler_field_view.inc \views_field_view_handler_field_view::options_form()

File

./views_field_view_handler_field_view.inc, line 37

Class

views_field_view_handler_field_view

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $options = drupal_map_assoc(array_keys(views_get_all_views()));
  unset($options[$this->view->name]);
  $form['view'] = array(
    '#type' => 'select',
    '#title' => t('View'),
    '#default_value' => $this->options['view'],
    '#options' => $options,
  );
  if ($this->options['view']) {
    $view = views_get_view($this->options['view']);
    $options = array();
    foreach ($view->display as $name => $display) {
      $options[$name] = $display->display_title;
    }
    $form['display'] = array(
      '#title' => t('Display'),
      '#type' => 'select',
      '#default_value' => $this->options['display'],
      '#options' => $options,
    );
    $form['arguments'] = array(
      '#title' => t('Arguments'),
      '#description' => t('Use a comma-seperated list of each argument which should be forwarded to the view') . $form['alter']['help']['#prefix'],
      '#type' => 'textfield',
      '#default_value' => $this->options['arguments'],
    );
    $form['query_aggregation'] = array(
      '#title' => t('Aggregate queries'),
      '#description' => t('Views Field View usually runs a separate query for each instance of this field on each row and that can mean a lot of queries.  This option attempts to aggregate these queries into one query per instance of this field (regardless of how many rows are displayed).  <strong>Currently child views must be configured to "display all values" if no argument is present and query aggregation is enabled.</strong>.  This may only work on simple views, please test thoroughly.') . $form['alter']['help']['#prefix'],
      '#type' => 'checkbox',
      '#default_value' => $this->options['query_aggregation'],
    );

    // Ensure we're working with a SQL view.
    if (views_api_version() == '3.0') {
      $views_data = views_fetch_data($view->base_table);
      if ($views_data['table']['base']['query class'] == 'views_query') {
        $form['query_aggregation']['#disabled'] = TRUE;
      }
    }
  }
  $form['alter']['#access'] = FALSE;
}