[Flow] Multi step form - save values in session

Alexander Berl a.berl at outlook.com
Sat Jun 29 17:04:23 CEST 2013


Hi Mark,

the session works by serialization/unserialization of the data, so for
it to work properly you need to make sure that the Object you want to
store can be properly serialized and unserialized, ie.
[igbinary_]unserialize([igbinary_]serialize($data)) == $data

I'm not sure how it would be possible that get_class($member) returns a
class name but the content of $member would be an array, so maybe I'm
getting something wrong.
I would rather suspect there is some small logic error in your code
somewhere, for example that the session data gets overwritten with array
data somewhere.

As to the propertyMapping, you are most likely just missing a proper
PropertyMappingConfiguration for all subproperties (assuming the
propertyMapper is properly injected and hence initialized and
is_array($session->getData('member')) is TRUE).

Here would be a good point to provide more information in form of full
code of your model and the dump output after retrieval from the session
and (if still relevant) after the property mapping.

Regards,
Alexander

Am 29.06.2013 06:59, schrieb Mark Kuiphuis:
> Hi all,
> 
> I am trying to get a form working which will be spread out over multiple
> pages. Each step will need to save the values in a session object.
> 
> So I have created a model with scope session which contains all the
> fields amongst the 6 steps in the form.
> 
> At the first "saveStep1Action()" where I create a new object of this
> model and assign the values from the form with setters and finally save
> the (partially completed) model in the session it all goes well.
> I don't want to put "rubbish" in the database yet, that's why I want to
> use the session
> 
> However, after wanting to save the values from the 2nd step of the form
> in the same model I first need to retrieve the model from the session.
> 
> So, I am using the following line of code to do that.
> 
> $session = $this->sessionManager->getCurrentSession();
> if ($session->hasKey('member')) {
>    $member = $session->getData('member');
> }
> 
> When I output this information with \TYPO3\Flow\var_dump($member) I do
> see the values from the 1st step in the form...so storing the session
> works well.
> 
> echo gettype($member) shows "Object" and
> echo get_type($member) shows "\My\Package\Domain\Session\Model\Member"
> (this model does exist in this non-conventional Flow folder)
> 
> I am unable to use any more setters on this model and save the newly
> updated model in the session again.
> 
> $session->getData('member') returns an array, although get_class and
> gettype tell me otherwise....
> 
> Because of the array being returned I have tried to use the
> propertyMapper to convert the session data to my model by issuing:
> 
> $member = $this->propertyMapper->convert($session->getData('member'),
> 'My\Package\Domain\Session\Model\Member');
> 
> but still it won't set the values from the second step of the form.
> 
> Anyone has any ideas how to save one session model in multiple steps?
> 
> Kind regards,
> 
> Mark Kuiphuis


More information about the Flow mailing list