Form Wizard is losing my data
Hello and thanks for your time! While trying to implement the Form Wizard I ran into a couple of problems. Using xdebug showed up that all submitted data is lost, what means:
$this->data, $_POST and $params['data'] / ['form'] are all empty. It seems that cake is doing some kind of redirect / dispatching and the actions are called twice. When I set a breakpoint in the beforeFilter() method, I can see all data filled in properly. There were some suggestions in other discussions that this could be caused by invalid links in the layout, but using an empty layout didnt change anything. I also removed the Auth Component, the RequestHandler, Helpers to see if theres something happening... nothing. Problem is, Im quite new to Cake and have no further ideas where to look. Currently Im getting this Warning:Warning (512): Step validation: daten is not a valid step. [ROOT/plugins/wizard/controllers/components/wizard.php, lin开发者_如何学编程e 271]
Code | Context
return $this->controller->autoRender ? $this->controller->render($this->_currentStep) : true;
} else {
trigger_error(sprintf(__('Step validation: %s is not a valid step.', true), $step), E_USER_WARNING);
$step = "daten"
WizardComponent::process() - ROOT/plugins/wizard/controllers/components/wizard.php, line 271
SignupsController::wizard() - ROOT/plugins/bookings/controllers/signups_controller.php, line 18
Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 204
Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
[main] - ROOT/webroot/index.php, line 83
Dont think that helps much, cause the $step array is also lost. Any idea deeply appreciated! :)
The issue is that the session has expired and the information is lost that the system keeps tracking progress and data with. Set your session to be longer in the security preferences in the core config. This still doesn't stop the error though. To fixed that replace:
trigger_error(sprintf(__('Step validation: %s is not a valid step.', true), $step), E_USER_WARNING);
to:
$this->reset();
This will send the user back to the first part of the form wizard. You will have lost all the user data but that happened by the session expiring in the first place or if someone tries to jump to a form which hasn't been accessed yet by using the form, it will also reset. This could be a good security measure or just plain annoying.
Anyway, that is my solution, there could be better ones.
精彩评论