Answer the question
In order to leave comments, you need to log in
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;
Answer the question
In order to leave comments, you need to log in
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.
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?
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 questionAsk a Question
731 491 924 answers to any question