Drupal 8.7.x
I have a custom form that currently replaces the form with the output of the form like so:
CalculationForm.php
public function submitForm(array &$form, FormStateInterface $form_state) {
...
// Result overview.
$result = [
'#theme' => 'THEME_calculation_overview',
'#name' => !empty($values['company_name']) ? $values['company_name'] : $form_state->getValue('firstname') . ' ' . $form_state->getValue('surname'),
'#product' => $product,
'#address' => $address,
'#results' => $result_clean,
'#urls' => $product_urls,
];
// Bundle (rendered) results.
$results_overview .= render($result);
// Show rendered results.
$this->response->addCommand(new ReplaceCommand('#form-calculation-container', $results_overview));
}
Currently the form submission makes an ajaxcall that replaces the container which holds the form with the rendered output (Replacecommand). Because we can't track the form submission with GTM I'm switching over to a normal form submission which redirects to a page.
My question is, how can I pass $results_overview to the redirect page and make it render as part of the content variable.
Thanks in advance