[Flow] Multi step form - save values in session
Mark Kuiphuis
typo3 at markyourweb.com
Sat Jun 29 06:59:21 CEST 2013
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