You are here

function views_calc_import_form_submit in Views Calc 6

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

FAPI import_form submit.

Submit handler for import form.

File

./views_calc.module, line 516
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_import_form_submit($form, &$form_state) {
  $form_values = $form_state['values'];
  $fields = NULL;

  // Use '@' to suppress errors about undefined constants in the macro.
  @eval($form_values['macro']);
  if (empty($fields) || !is_array($fields)) {
    return;
  }
  foreach ($fields as $delta => $field) {

    // Don't over-write existing fields, create new ones.
    $fields[$delta]['cid'] = NULL;
  }

  // Run the values thru drupal_execute() so they are properly validated.
  $form_state = array(
    'values' => $fields,
  );
  drupal_execute('views_calc_fields_form', $form_state);
}