public function WebformResultsExportForm::submitForm in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Form/WebformResultsExportForm.php \Drupal\webform\Form\WebformResultsExportForm::submitForm()
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/ WebformResultsExportForm.php, line 83
Class
- WebformResultsExportForm
- Webform for webform results export webform.
Namespace
Drupal\webform\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$default_options = $this->submissionExporter
->getDefaultExportOptions();
$export_options = $this->submissionExporter
->getValuesFromInput($form_state
->getValues());
// Implode arrays.
foreach ($export_options as $key => $value) {
if (is_array($default_options[$key]) && is_array($value)) {
$export_options[$key] = implode(',', $value);
}
}
$webform = $this->submissionExporter
->getWebform();
if ($source_entity = $this->submissionExporter
->getSourceEntity()) {
$entity_type = $source_entity
->getEntityTypeId();
$entity_id = $source_entity
->id();
$route_parameters = [
$entity_type => $entity_id,
];
if ($webform) {
$route_parameters['webform'] = $webform
->id();
}
$route_options = [
'query' => $export_options,
];
$form_state
->setRedirect('entity.' . $entity_type . '.webform.results_export', $route_parameters, $route_options);
}
elseif ($webform) {
$route_parameters = [
'webform' => $webform
->id(),
];
$route_options = [
'query' => $export_options,
];
$form_state
->setRedirect('entity.webform.results_export', $route_parameters, $route_options);
}
}