You are here

function views_calc_fields_form in Views Calc 5

Same name and namespace in other branches
  1. 6.3 views_calc.module \views_calc_fields_form()
  2. 6 views_calc.module \views_calc_fields_form()
  3. 7 views_calc.module \views_calc_fields_form()

Views Calc Fields tab on views list.

1 string reference to 'views_calc_fields_form'
views_calc_menu in ./views_calc.module

File

./views_calc.module, line 159
This module will allow you to add calculated fields to views tables and compute (SUM, COUNT, AVG, etc) columns of numeric data in a views table.

Code

function views_calc_fields_form() {
  $i = 0;
  $substitutions = _views_calc_substitutions();
  $reverse = array_flip($substitutions);

  // display current views calcs fields
  $fields = _views_calc_fields();
  while ($field = db_fetch_array($fields)) {
    $form[] = views_calc_field_form_item($i, $field, $substitutions);
    $i++;
  }

  // add blank fields for more calcs
  for ($x = $i + 1; $x < $i + 2; $x++) {
    $field = array();
    $form[] = views_calc_field_form_item($i, $field, $substitutions);
  }
  $form['#prefix'] = '<div class="views-calc-field-settings">';
  $form['#suffix'] = '</div><div class="views-calc-field-names"><strong>Field Substitutions</strong><div class="form-item">' . theme('item_list', _views_calc_substitutions()) . '</div></div>';
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}