Open JoostFaber opened 3 years ago
Have you tried to use the entity manager to get the saved data and replace the current form data with that before going to the next step? That is probably what I would try.
I gave the users the option to save the form and come back to it later in my app and I do this operation just after the valid check.
if( $flow->isValid($form) ){
......
// if we find that save progress is set to true we save everything and redirect to is order list.
if( $request->get($form->getName())['saveProgress'] == true){
$this->addFlash('success','Order successfully saved!');
// flow finished
$em = $this->getDoctrine()->getManager();
$em->persist($order);
$em->flush();
$flow->reset(); // remove step data from the session
return $this->redirect($this->generateUrl('orders')); // redirect when done
}
......
}
Hello,
Im using this bundle for the creation of a course, so that the create process is separated into multiple steps. For each step I’m using the same FormType which contains some CollectionTypes to create a multi level nested form. To keep things simple I will only describe the first 2 steps.
Form1 = General course information which has the course entity as data class + CollectionType for the entity ‘specialization’ Form2 = Course objectives (which contains an EntityType of the specializations rendered as checkboxes)
Although the general purpose of this bundle is to store the data in the session until all steps are completed I have changed to example code a bit to save it at each step.
`public function createCourseNew(Request $request) { $em = $this->getDoctrine()->getManager(); $formData = new Course(); $flow = $this->get("form.flow.courseflow");
}`
The problem i'm facing is that the specializations that I have created in step 1 aren't shown in the EntityType field in step 2 although the specializations are saved in the DB after submitting step 1. I only see specializations that where already saved in the DB earlier.
Only after manual refreshing the page at step 2 these specialization records from step 1 are shown.
form step 1![github step 1](https://user-images.githubusercontent.com/11028935/101789506-ab4eb400-3b01-11eb-8a8f-44905bdc99ca.png)
confirmation of saved data![DB records](https://user-images.githubusercontent.com/11028935/101789534-b6a1df80-3b01-11eb-905e-7aa2ad700f8d.png)
before refresh![step 2 before refresh](https://user-images.githubusercontent.com/11028935/101789466-a0941f00-3b01-11eb-9f42-551cf4e05ca7.png)
after refresh![step 2 after refresh](https://user-images.githubusercontent.com/11028935/101789486-a558d300-3b01-11eb-8ad6-bc3273665b58.png)
So my question is when are these forms populated with the data? Because from this behavior it looks like every form gets populated from step 1 (it only loads the specializations that were submitted ealier and not the specializations that are created from step 1)