public function ParameterForm::submitForm in Forena Reports 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ ParameterForm.php, line 253
Class
Namespace
Drupal\forena\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
unset($values['parms']['submit']);
if (isset($values['parms'])) {
foreach ($values['parms'] as $key => $value) {
$ctl = $form['parms'][$key];
switch ($ctl['#type']) {
case 'date_popup':
case 'date_select':
case 'date_text':
$datetime = @strtotime($value);
if ($datetime) {
$value = $values['parms'][$key] = date($ctl['#forena_date_format'], $datetime);
}
break;
}
if (is_array($value)) {
$values['parms'][$key] = array();
foreach ($value as $k => $val) {
if ($val) {
$values['parms'][$key][] = $val;
}
}
}
else {
if (strpos($value, '|') !== FALSE) {
$values['parms'][$key] = explode('|', $value);
}
elseif ($value === '' || $value === NULL) {
unset($values['parms'][$key]);
}
}
}
}
$path = \Drupal::service('path.current')
->getPath();
$url = Url::fromUserInput($path, [
'query' => $values['parms'],
]);
$form_state
->setRedirectUrl($url);
}