title: Symfony2, form multi steps with CraueFormFlowBundle
body: <p>I'm trying to build a multi-steps form with <a href="https://github.com/craue/CraueFormFlowBundle" rel="nofollow">CraueFormFlowBundle</a>. For the moment, I can go to the first step (users information), but I have an error when I click on the "NEXT" button.</p>
  
  <p>My first step is a form data type based on my User entity, and the second step is another form data type based on entity Etablissement (another entity).</p>
  
  <p>There is my error message :</p>
  
  <p>The form's view data is expected to be an instance of class AppBundle\Entity\Etablissement, but is an instance of class AppBundle\Entity\User. 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 AppBundle\Entity\User to an instance of AppBundle\Entity\Etablissement. </p>
  
  <p>The file configuration steps :</p>
  
  <pre><code>namespace AppBundle\Form;
  
  // AppBundle/Form/RegistrationEtablissementFlow.php
  use Craue\FormFlowBundle\Form\FormFlow;
  use Craue\FormFlowBundle\Form\FormFlowInterface;
  use Symfony\Component\Form\FormTypeInterface;
  
  class EnregistrementCompletFlow extends FormFlow {
  
      /**
       * @var FormTypeInterface
       */
      protected $formType;
  
      public function setFormType(FormTypeInterface $formType) {
          $this-&gt;formType = $formType;
      }
  
      public function getName() {
          return 'enregistrementComplet';
      }
  
      protected function loadStepsConfig() {
          return array(
              array(
                      'label' =&gt; 'Infos personnelles',
                      'form_type' =&gt; 'homes_user_registration', // the user's form registered as sevice
              ),
              array(
                      'label' =&gt; 'Infos établissement',
                      'form_type' =&gt; 'likabee_form_etablissement', // the etablissement's form registered as sevice
                      //'form_type' =&gt; $this-&gt;formType,
              ),
              array(
                      'label' =&gt; 'confirmation',
              ),
          );
      }
  }
  </code></pre>
  
  <p>In my controller :</p>
  
  <pre><code>/**
       * @Route("/registration-etablissement", name="registrationEtablissement")
       */
      public function registrtationEtablissementAction()
      {
          $formData = new User();
          $formData-&gt;setEtablissement( new Etablissement());
  
          $flow = $this-&gt;get('likabee.form.flow.enregistrementComplet'); // must match the flow's service id
          $flow-&gt;bind($formData);
  
          // form of the current step
          $form = $flow-&gt;createForm();
          if ($flow-&gt;isValid($form))
          {
              $flow-&gt;saveCurrentStepData($form);
  
              if ($flow-&gt;nextStep())
              {
  
                  // form for the next step
                  $form = $flow-&gt;createForm();
              }
              else
              {
                  // flow finished
  
                  $em = $this-&gt;getDoctrine()-&gt;getManager();
                  $em-&gt;persist($formData);
                  $em-&gt;flush();
  
                  $flow-&gt;reset(); // remove step data from the session
  
                  return $this-&gt;redirect($this-&gt;generateUrl('index')); // redirect when done
              }
          }
  
          return $this-&gt;render('registrationEtablissement.html.twig', array(
                  'form' =&gt; $form-&gt;createView(),
                  'flow' =&gt; $flow,
          ));
      }
  </code></pre>
  
  <p>I think that when i'm going to the second step, the form waiting a User type, and not an Etablissement type, but I don't know how to resolve this ...</p>
  
  <p>Thanks in advance ...</p>