We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is my controller. I'm trying to make the "redirect after submit" option work:
public function showCounselingFlow(CounselingRequestFlow $formFlow, FormFlowUtil $util, Request $request) { $model = new CounselingRequest(); $formFlow->bind($model); $form = $formFlow->createForm(); if ($formFlow->isValid($form)) { $formFlow->saveCurrentStepData($form); if (!$formFlow->nextStep()) { $formFlow->reset(); return $this->redirectToRoute('_complete'); } if ($formFlow->redirectAfterSubmit($form)) { return $this->redirectToRoute( $request->attributes->get('_route'), $util->addRouteParameters($request->attributes->get('_route_params'), $formFlow) ); } $form = $formFlow->createForm(); } return [ 'form' => $form->createView(), 'flow' => $formFlow, ]; }
http://localhost/?instance=eo-6lVKSna&step=2
Am I'm doing something wrong in my controller?
The text was updated successfully, but these errors were encountered:
Did you find a solution?
Thanks to #221 I think I've found a working solution:
<?php namespace App\Controller; use App\Form\TherapyRequestFlow; use App\Form\TherapyRequestModel; use Craue\FormFlowBundle\Util\FormFlowUtil; use Symfony\Bridge\Twig\Attribute\Template; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\HttpFoundation\RedirectResponse; class TestController extends AbstractController { #[Route('/test', name: 'app_test')] #[Template('test/index.html.twig')] public function test(TherapyRequestFlow $flow, FormFlowUtil $utils, Request $request): RedirectResponse|array { $model = new TherapyRequestModel(); $flow->bind($model); $form = $submittedForm = $flow->createForm(); if ($flow->isValid($form)) { $flow->saveCurrentStepData($form); if (!$flow->nextStep()) { $flow->reset(); dd($model); } $form = $flow->createForm(); } if ($flow->redirectAfterSubmit($submittedForm)) { // IMPORTANT: do not use $form return $this->redirectToRoute( $request->attributes->get('_route'), $utils->addRouteParameters( [ ...$request->query->all(), ...$request->attributes->get('_route_params'), ], $flow, ) ); } return [ 'form' => $form, 'flow' => $flow, ]; } }
Sorry, something went wrong.
No branches or pull requests
Here is my controller. I'm trying to make the "redirect after submit" option work:
http://localhost/?instance=eo-6lVKSna&step=2
)Am I'm doing something wrong in my controller?
The text was updated successfully, but these errors were encountered: