Feature #70384
closedMake it possible to redirect (instead of forwarding) to referring action on validation error
0%
Description
When a validation error happens during form submission, the errorAction() forwards request to a previously called action and provides validation results to be shown and used on Fluid form.
However, when a form consists of multiple steps and each step is located on different page this leads to a problem: a page of next step is shown (all the surrounding CEs of next step are there), but the form from a previous step is displayed.
It would be helpful to have a possibility to redirect() to a previous step and preserve validation errors as well as user input.
I have tried to do it on my own, and found some solution for 2-step forms. However, for 3- and more steps this will fail.
https://forum.typo3.org/index.php/t/212078/
Updated by Christian Weiske about 8 years ago
This would also help in scenarios where the input form is on a different page as the output plugin, e.g. a search form on the home page, and the result list on a separate page.
Currently extbase executes the search form action on the result list page. This leads to the problem that all the search form plugin settings are not available anymore, breaking the search form output.
Updated by Nicole Cordes about 8 years ago
- Status changed from New to Needs Feedback
Hi Viktor,
You can simply overwrite the errorAction() of your controller and do whatever you want if an error occurs. The thing is that e.g. post requests can't be redirected to another action as that would mean loosing your data.
Updated by Viktor Livakivskyi about 8 years ago
Hi Nicole,
Yes, I've tried to perform overrides and partly succeeded with it. But the problem appears in case of object creation and form has 3 or more steps, represented by 3 actions in controller:
->step1() ->step2(MyObject $object) ->step3(MyObject $object)
In such case, if a validation error appears when going from step 2 to step 3, we'll need to redirect to step 2, which expects MyObject
to be passed as an argument, and due to a fact, that object is not yet persisted, the UriBuilder fails to create a proper URL, since object has no uid yet.
I see, that it is a limitation of HTTP POST submitted forms - they can't be easily transformed into GET requests (special show-stopper would be submitted file).
The only question, that still remains: is it possible to have different pages for different steps of object creation? Or to be more specific: have different content blocks, which are surrounding plugin?
This surely can be achieved by using FlexForm of a plugin and insert CEs there, but with complex structures and translations it'll become a nightmare.
Updated by Alexander Opitz almost 8 years ago
- Status changed from Needs Feedback to New
Updated by Susanne Moog over 4 years ago
- Status changed from New to Closed
There is no easy way to solve multi-step forms in a generic manner. I would suggest to use ViewObjects / DTOs for the single steps and validate those (if the steps are not necessarily validated in conjunction). Another API provided way would be to use the PHP-API of the TYPO3 FormFramework to build more complex multi-page/multi-step forms with validation. Please refer to the documentation for examples.
I'm going to close this issue now as I don't see a way to make this possible in general for all cases.
Updated by Simon Schaufelberger 6 months ago
- Related to Bug #97647: Forward to referring controller causes Property Mapping exception added
Updated by Simon Schaufelberger 6 months ago
- Related to Bug #89434: Action argument values will get lost on validation error added