I am a newbie in DRUPAL8 and so I need help.
It is for scientist domain: all calculations must not be disclosed, so, must be done on server.
I built a main page (page1) to fill with parameters (manually or from database) (until 50 fields) and submit button. This page is built with webform on DRUPAL8.
Some parameters are complex and must be computed with other combinate parameters (until 30 fields). For UX, I have introduced a second form (PHP handmade) displayed in a second page (page2) called, from main, page with push button (onclick=”window.open(‘/page2’, ‘_blank’)” + route in the myModule.routing.yml). It works.
Aim is to send computed parameters from page2 and fill page1 with it.
The question: how to do with setRedirect() and route?
That I have already tried without success:
First, and I think that is the best way, I used $form_state->setRedirect(‘route’, (‘result’ => $complexParam)) but I don’t know how to define ‘route’ in myModule.routing.yml because webform in page1 is placed in the root of my project, not in _form or _controller. What is the route to define in myModule.routing.yml to reach it?
Second, I used $form_state->setRedirect(‘entity.node.canonical’, (‘node’ => 5), (‘query’ => (‘result’ => $complexParam))). Ok, this solution closes my page2 but built a new page1 and I have a understandable message: ‘Warning: Use of undefined constant ‘query’ – assumed ‘‘query’’ (this will throw an Error in a future version of PHP) in Drupal myModuleFormpage2->submitForm()’. I found this example in the forum but as a newbie, I don’t know how to manage this ‘query’. I have decided to use session variables to exchange $complexParam between page2 and page 1. Is it a good solution?
At least, I explored the multi-step webform solution, but the user can modify several times $complexParam. Note that there are not only page2 but page3 and page4 must be managed (3 complex parameters)