craue/CraueFormFlowBundle — Issue #18: Loosing options when going one step back
Author: arnaugm
Created: 2012-02-21 16:36:18+00:00
State: open

I have a form with two steps and I need the user object in form part of the first step.
In the controller I pass the user to the form.

$form = $flow->createForm($entity, array('user' => $user));

I set the option in the form type

public function getDefaultOptions(array $options) {
$options = parent::getDefaultOptions($options);

$options['flowStep'] = 1;
$options['data_class'] = 'MyBundle\Entity\MyEntity';
$options['user'] = null;

return $options;
}

and I retrieve it in the buildForm function

public function buildForm(FormBuilder $builder, array $options)
{
$user = $options['user'];

switch ($options['flowStep']) {
...

It works at the beginning, but if in the second step I click on the back button, I got an error because the user is not in options anymore.

How can I do that?

Thank you.