Open rtwent opened 8 years ago
I can confirm this bug. Any ideas why ?
@rtwent We can't save functions into session :(,
In your controlle do:
$model['_validators'] = [];
$event->data = $model;
@BenasPaulikas I decided this issue by using custom validators (http://www.yiiframework.com/doc-2.0/guide-input-validation.html#creating-validators). They work perfect. Yes, the problem that it is impossible to save lambda function in session http://stackoverflow.com/questions/16788049/storing-function-in-session-variable
same problem like mention above .Please provide a solution for it.
I use simple DTO model for save data. My method of getting model for current step:
/**
* Return form model for current step. Get it from WizardBehavior (session) or create new.
*
* @uses forms (AllocationSectionForm, CompanyInfoForm, GoodsInfoForm) from core\forms\partner\signup\
* @return Model
*/
private function getWizardModel($event)
{
$modelName = 'core\\forms\\partner\\signup\\' . ucfirst($event->step);
if (empty($event->stepData)) {
return new $modelName();
}
$model = new $modelName();
$model->setAttributes($event->stepData->attributes(), false);
return $model;
}
When step model has conditional validation callback function (https://github.com/yiisoft/yii2/blob/master/docs/guide/input-validation.md#user-content-conditional-validation-) the wizard end() its work and redirect to invalidStep.