In submitForm() I want to redirect to a controller and pass the form values. The form values are all arrays, btw.
Here is submitForm.
public function submitForm(array &$form, FormStateInterface $form_state) {
// get values
$demo_values = $form_state->getValue('demo');
$data_set_value = $form_state->getValue('data_set');
$engineering_degrees1 = $form_state->getValue('engineering_degrees1');
$engineering_degrees2 = $form_state->getValue('engineering_degrees2');
$engineering_degrees3 = $form_state->getValue('engineering_degrees3');
$engineering_degrees4 = $form_state->getValue('engineering_degrees4');
$physical_science_degrees = $form_state->getValue('physical_science_degrees');
# set form data in url redirect
$params = ['demos' => $demo_values,
'data_set' => $data_set_value,
'engineering_degrees1' => $engineering_degrees1,
'engineering_degrees2' => $engineering_degrees2,
'engineering_degrees3' => $engineering_degrees3,
'engineering_degrees4' => $engineering_degrees4,
'physical_science_degrees' => $physical_science_degrees];
$form_state->setRedirect('stats_degrees.render_chart',$params);
}
}
Here is my routing YML file.
stats_degrees.render_form:
path: '/statistics/stats-degrees'
defaults:
_title: 'Engineering and Physical Science Degrees Earned by Members of Underrepresented Groups'
_form: '\Drupal\stats_degrees\Form\StatsDegreesForm'
requirements:
_permission: 'access content'
stats_degrees.render_chart:
path: '/statistics/stats-degrees-chart/{demos}/{data_set}/{engineering_degrees1}/{engineering_degrees2}/{engineering_degrees3}/{engineering_degrees4}/{physical_science_degrees}'
defaults:
_controller: '\Drupal\stats_degrees\Controller\StatsDegreesController::stats_degrees_chart'
requirements:
_permission: 'access content'
Here is my Controller method call.
public function stats_degrees_chart($demos,$data_set,$engineering_degrees1,$engineering_degrees2,$engineering_degrees3,$engineering_degrees4,$physical_science_degrees) {
Currently, it's throwing a 500 error after I submit the form. Is there a better way to pass the parameters to the controller?