class PostSignUpWizardController extends Controller
{
/**
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
* @throws \InvalidArgumentException
* @throws \LogicException
*/
public function wizardAction()
{
$flow = $this->get('business_main.service.sign_up_wizard'); // must match the flow's service id
$formData = new CategoryChooserFormDataClass(); // Your form data class. Has to be an object, won't work properly with an array.
$flow->bind($formData);
// form of the current step
$form = $flow->createForm();
if ($flow->isValid($form)) {
$flow->saveCurrentStepData($form);
if ($flow->nextStep()) {
// form for the next step
$form = $flow->createForm();
} else {
// flow finished
$em = $this->getDoctrine()->getManager();
$em->persist($formData);
$em->flush();
$flow->reset(); // remove step data from the session
return $this->redirect($this->generateUrl('home')); // redirect when done
}
}
return $this->render('@BusinessMain/Wizard/post_sign_up_wizard.html.twig', [
'form' => $form->createView(),
'flow' => $flow,
]);
}
}
Step 1 render goes fine
But upon pressing next , I get the error
The form's view data is expected to be an instance of class Business\MainBundle\Form\DataClass\BusinessNameFormDataClass, but is an instance of class Business\MainBundle\Form\DataClass\CategoryChooserFormDataClass. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms an instance of class Business\MainBundle\Form\DataClass\CategoryChooserFormDataClass to an instance of Business\MainBundle\Form\DataClass\BusinessNameFormDataClass.
So my question is how to configure flow/controller in order to make use of two forms with different data_class? Thanks
Hi, I have a form type
and
Data Classes
and
Flow class
Controller
Step 1 render goes fine
But upon pressing next , I get the error
The form's view data is expected to be an instance of class Business\MainBundle\Form\DataClass\BusinessNameFormDataClass, but is an instance of class Business\MainBundle\Form\DataClass\CategoryChooserFormDataClass. You can avoid this error by setting the "data_class" option to null or by adding a view transformer that transforms an instance of class Business\MainBundle\Form\DataClass\CategoryChooserFormDataClass to an instance of Business\MainBundle\Form\DataClass\BusinessNameFormDataClass.
So my question is how to configure flow/controller in order to make use of two forms with different data_class? Thanks