title: Symfony2 merge multi step form to one result
body: <p>These are my first steps on SF2. I want to set up a multi step form on an entity which contains other entities.</p>
  
  <p>I've a form type (shortened)</p>
  
  <pre><code>class ApplicationFormType extends AbstractType
  {
      protected $_step = 1;
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          if ($this-&gt;_step == 1) {
              $builder
                  -&gt;add('patient', new Type\PersonType())
                  -&gt;add('insurance', 'entity', array(
                      'class' =&gt; 'Acme\MainBundle\Entity\Insurance',
                  ));
          } elseif ($this-&gt;_step == 2) {
              $nurse = new Type\PersonType();
              $nurse-&gt;requireBareData();
              $builder
                  -&gt;add('nurse', $nurse)
                  -&gt;add('nurse_type', 'entity', array(
                      'class' =&gt; 'Acme\MainBundle\Entity\NurseType',
                      'expanded' =&gt; true,
                      'multiple' =&gt; false,
                  ))
                  -&gt;add('nursing_support', 'checkbox', array(
                      'required' =&gt; false,
                  ));
          }
      }
  
      public function setStep($step)
      {
          $this-&gt;_step = $step;
      }
  </code></pre>
  
  <p>My controller looks like</p>
  
  <pre><code>public function assistAction() {
      $request = $this-&gt;getRequest();
  
      $step = $this-&gt;getSession()-&gt;get('assist_step', 1);
      if ($request-&gt;getMethod() != 'POST') {
          $step = 1;
          $this-&gt;getSession()-&gt;set('assist_data', NULL);
      }
      $this-&gt;getSession()-&gt;set('assist_step', $step);
      $application = new Application();
      $type = new ApplicationFormType();
      $type-&gt;setStep($step);
  
      $form = $this-&gt;createForm($type, $application, array(
          'validation_groups' =&gt; array($step == 1 ? 'FormStepOne' : 'FormStepTwo'),
      ));
      if ($request-&gt;getMethod() == 'POST') {
          $form-&gt;bindRequest($request);
          if ($form-&gt;isValid()) {
              if ($step == 1) {
  
                  $data = $form-&gt;getData();
                  $this-&gt;getSession()-&gt;set('assist_data', serialize($data));
                  $this-&gt;getSession()-&gt;set('assist_step', ++$step);
                  $type = new ApplicationFormType();
                  $type-&gt;setStep($step);
                  $form = $this-&gt;createForm($type, $application, array(
                      'validation_groups' =&gt; array('FormStepTwo'),
                  ));
  
              } else {
  
                  $step_1 = unserialize($this-&gt;getSession()-&gt;get('assist_data', ''));
                  $data = $form-&gt;getData();
  =&gt;                $data-&gt;setPatient($step_1-&gt;getPatient());
  =&gt;                $data-&gt;setInsurance($step_1-&gt;getInsurance());
                  $this-&gt;getSession()-&gt;set('assist_data', NULL);
                  $this-&gt;getSession()-&gt;set('assist_step', 1);
  
              }
          }
      }
  
      return $this-&gt;render('Acme:Default:onlineassist.html.twig', array(
          'form' =&gt; $form-&gt;createView(),
          'step' =&gt; $step,
      ));
  }
  </code></pre>
  
  <p>My question is, if I had to "copy" the properties of first form step seperately, like:</p>
  
  <pre><code>$data-&gt;setPatient($step_1-&gt;getPatient());
  $data-&gt;setInsurance($step_1-&gt;getInsurance());
  </code></pre>
  
  <p>or can I merge the unserialized data from session with data from second form step?
  Or is there a completely different approach?</p>