You are here

function forena_parameter_form_submit in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 forena.common.inc \forena_parameter_form_submit()
  2. 7.5 forena.module \forena_parameter_form_submit()
  3. 7 forena.common.inc \forena_parameter_form_submit()
  4. 7.2 forena.common.inc \forena_parameter_form_submit()
  5. 7.4 forena.module \forena_parameter_form_submit()

gets the values from the params form redirects to the report page with the values in the querystring.

File

./forena.module, line 685

Code

function forena_parameter_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  unset($values['params']['submit']);
  if (isset($values['params'])) {
    foreach ($values['params'] as $key => $value) {
      $ctl = $form['params'][$key];
      switch ($ctl['#type']) {
        case 'date_popup':
        case 'date_select':
        case 'date_text':
          $datetime = @strtotime($value);
          if ($datetime) {
            $value = $values['params'][$key] = date($ctl['#forena_date_format'], $datetime);
          }
          break;
      }
      if (is_array($value)) {
        $values['params'][$key] = array();
        foreach ($value as $k => $val) {
          if ($val) {
            $values['params'][$key][] = $val;
          }
        }
      }
      else {
        if (strpos($value, '|') !== FALSE) {
          $values['params'][$key] = explode('|', $value);
        }
        elseif ($value === '' || $value === NULL) {
          unset($values['params'][$key]);
        }
      }
    }
  }
  $form_state['redirect'] = array(
    $_GET['q'],
    array(
      'query' => @$values['params'],
    ),
  );
}