function views_calc_cols_form in Views Calc 5
Views Calc Columns tab on views list.
1 string reference to 'views_calc_cols_form'
File
- ./
views_calc.module, line 187 - 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_cols_form() {
$form = array();
$views = _views_calc_view_views();
while ($val = db_fetch_array($views)) {
if ($vid = $val['vid']) {
$view = views_get_view($vid);
$fields = $view->field;
$options = array(
'' => '',
);
foreach ($fields as $key => $field) {
$options[$field['fullname']] = $field['label'];
}
$calcs = _views_calc_calc_options();
$form['views_calc'][$vid] = array(
'#type' => 'fieldset',
'#title' => t('View: ') . $view->name,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['views_calc'][$vid]['views_calc_' . $vid . '_col'] = array(
'#type' => 'select',
'#title' => t('Columns for column calculation'),
'#default_value' => variable_get('views_calc_' . $vid . '_col', ''),
'#options' => $options,
'#multiple' => TRUE,
'#description' => t('Add a calculation at the foot of each these columns.'),
);
$form['views_calc'][$vid]['views_calc_' . $vid . '_col_calc'] = array(
'#type' => 'select',
'#title' => t('Calculations to perform on columns'),
'#default_value' => variable_get('views_calc_' . $vid . '_col_calc', ''),
'#options' => $calcs,
'#multiple' => TRUE,
);
}
}
if (sizeof($form) == 0) {
drupal_set_message(t('There are no views with the Views Calc page type. Create a view with that page type, then return here to set up column calculations.'), 'error');
}
else {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
return $form;
}