You are here

function webform_analysis_components_form in Webform 7.4

Form for selecting which components should be shown on the analysis page.

1 string reference to 'webform_analysis_components_form'
webform_results_analysis in includes/webform.report.inc
Provides a simple analysis of all submissions to a webform.

File

includes/webform.report.inc, line 1825
This file includes helper functions for creating reports for webform.module.

Code

function webform_analysis_components_form($form, &$form_state, $node) {
  form_load_include($form_state, 'inc', 'webform', 'includes/webform.components');
  $form['#node'] = $node;
  $component_list = webform_component_list($node, 'analysis', TRUE);
  $enabled_components = webform_analysis_enabled_components($node);
  if (empty($component_list)) {
    $help = t('No components have added that support analysis. <a href="!url">Add components to your form</a> to see calculated data.', array(
      '!url' => url('node/' . $node->nid . '/webform'),
    ));
  }
  elseif (empty($enabled_components)) {
    $help = t('No components have analysis enabled in this form. Enable analysis under the "Add analysis components" fieldset.');
  }
  else {
    $help = t('This page shows analysis of submitted data, such as the number of submissions per component value, calculations, and averages. Additional components may be added under the "Add analysis components" fieldset.');
  }
  $form['help'] = array(
    '#markup' => '<p>' . $help . '</p>',
    '#access' => !empty($help),
    '#weight' => -100,
  );
  $form['components'] = array(
    '#type' => 'select',
    '#title' => t('Add analysis components'),
    '#options' => $component_list,
    '#default_value' => $enabled_components,
    '#multiple' => TRUE,
    '#size' => 10,
    '#description' => t('The selected components will be included on the analysis page.'),
    '#process' => array(
      'webform_component_select',
    ),
    '#access' => count($component_list),
  );
  $form['actions'] = array(
    '#type' => 'actions',
    '#access' => count($component_list),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update analysis display'),
  );
  return $form;
}