A
A
Alexey Verkhovtsev2019-05-05 17:55:08
symfony
Alexey Verkhovtsev, 2019-05-05 17:55:08

How to make a redirect and pass the previously filled Symfony data to the form?

I am processing a form.

$form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $stripePlanCreateDTO = $form->getData();
            try {
                $stripePlan =
                    $this->stripePlanService->createStripePlan(
                        $stripePlanCreateDTO
                    );
            } catch (UserExceptionInterface $e) {
                $this->addFlash(
                    'error',
                    $e->getMessage()
                );

                return $this->redirectToRoute(
                    'admin.stripe_plans.create'
                );
            }

            $this->addFlash(
                'success',
                $stripePlan->name()
                . ' was added successfully.'
            );

            return $this->redirectToRoute('admin.stripe_plans.get_all');
        }

The whole problem is that if there is an exception and a redirect occurs, then it is clear that the form data that the user has already filled out will be lost. In Laravel you can do something like return back()->withErrors([$e->getMessage()])->withInput(); but how to do it on siphon, tell me please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
teotlu, 2017-04-11
@teotlu

What's the problem? position: absolute works as it should by default. You just need to make white-space: nowrap so that the items do not wrap. Well, use a negative indent on the left, equal to the inner indent of the dropdown, to align the text of the dropdown with the text of the control itself.
https://jsfiddle.net/e1wzyL9L/1/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question