craue / CraueFormFlowBundle

Multi-step forms for your Symfony project.
MIT License
736 stars 118 forks source link

How to get unmapped form data after submit ? #307

Closed eved42 closed 6 years ago

eved42 commented 6 years ago

I have a simply form flow with two steps. In the first step, I have all the fields of my entity with two other unmapped fields.

When I submit the form (final step), how can I get these two fields ?

In my controller, I tried this : $flow->getDataManager()->getStorage()->get('craue_form_flow');

Returns :

array(
    name of the flow => array(
        instance id of the flow => array(
            'data' => array() // the actual step data
        )
    )
 )

My problem is that I don't know the current instance id of the flow. Any idea ?

eved42 commented 6 years ago

I found the solution :

// get form data (with unmapped fields)
$store = $flow->getDataManager()->getStorage()->get('craue_form_flow')['nameOfTheFlow'];
$data = $store[$flow->getInstanceId()]['data'][1];

// [...] do some stuff

$flow->reset(); // remove step data from the session