L
L
lenuska7732015-04-02 16:05:00
symfony
lenuska773, 2015-04-02 16:05:00

Symfony how to make redirect forms?

Good afternoon,
Perhaps someone knows how to make a forward from one form to another.
I mean, I have an Add button on one form, by this button I launch the second form. It works. I enter the data, I click in the second button button "Ok" (Submit). It goes into the controller, saves the data, BUT,
in the controller I use

$response = $this->forward('ProductBundle:Action:createForm', array(
          'parent_id' =>$parent_id
      ));
        
      return $response;

It redirects to the first controller, but the old form field remains, the new form field remains, and the Ok (Submit) button of the first form for some reason reacts like the Ok (Submit) of the second form.
Something like this))
Maybe someone knows how to make a forward so that the second form is completely closed and the first one is opened.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2015-04-03
@lenuska773

Why don't you like collections ? And you don't need any redirects...
If you want a modal window with a form, then create a feature with Ajax and, if successful, add the newly created feature to the main form and close the modal window. (Example in SonataAdmin)
Another option, more complicated. You create a product form, add a characteristic form to it and add another submit button, in the controller (if your form is being processed in it), after submitting the form, you get a button and check it for "isClicked", then implement the logic here for more details .
Another way. After creating a product, redirect to feature creation, passing in the product id.
Depending on the table relationships Product <-> Characteristics, the implementation of this solution may be different. How are they connected to you? One to many, many to many, or something else?
In your case, when you move on to creating a feature, you need to save the state of the product, then, upon successful creation of the feature, return and restore the product. Then everything will work. But this is a very bad decision.

A
Alex, 2015-04-02
@shoomyst

It is very chaotically described, it is difficult to understand something)
You can guess for a long time, did you mix up the parameters in forward?

A
Alexander Evgenievich, 2015-04-02
@banderos120

If the front is crooked, then the front is crooked - here only the pattern break will help, what you have depends on what.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question