You are here

function views_calc_table::options_form in Views Calc 6.3

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

Render the given style.

File

./views_calc_table.inc, line 28
Copied from the table style plugin.

Class

views_calc_table
Style plugin to render each item as a row in a table.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['#theme'] = 'views_calc_ui_table';
  $form['detailed_values'] = array(
    '#title' => t('Show details'),
    '#type' => 'select',
    '#options' => array(
      0 => t('Yes'),
      1 => t('No'),
    ),
    '#default_value' => $this->options['detailed_values'],
    '#description' => t("Select 'Yes' to show detailed values followed by column calculations, 'No' to surpress details and show only calculated column totals."),
  );
  $handlers = $this->display->handler
    ->get_handlers('field');
  $columns = $this
    ->sanitize_columns($this->options['columns']);
  foreach ($columns as $field => $column) {
    $safe = str_replace(array(
      '][',
      '_',
      ' ',
    ), '-', $field);
    $id = 'edit-style-options-columns-' . $safe;
    $form['info'][$field]['has_calc'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display calculation'),
      '#default_value' => isset($this->options['info'][$field]['has_calc']) ? $this->options['info'][$field]['has_calc'] : 0,
      '#process' => array(
        'views_process_dependency',
      ),
      '#dependency' => array(
        $id => array(
          $field,
        ),
      ),
    );
    $options = _views_calc_calc_options();
    $form['info'][$field]['calc'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => isset($this->options['info'][$field]['calc']) ? $this->options['info'][$field]['calc'] : array(),
      '#process' => array(
        'views_process_dependency',
      ),
      '#dependency' => array(
        'edit-style-options-info-' . $safe . '-has-calc' => array(
          TRUE,
        ),
      ),
      '#multiple' => TRUE,
    );
  }
}