yii2-wizard
yii2-wizard copied to clipboard
I use example, but return empty page
I use example, but return empty page
public function quizWizardStep($event)
{
$modelName = 'app\models\wizard\quiz\Question';
$model = new $modelName(['question' => $this->questions[$event->n]]);
$t = count($this->questions);
debug($model);
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$event->data = $model;
$event->nextStep = ($event->n < $t - 1
? WizardBehavior::DIRECTION_REPEAT
: WizardBehavior::DIRECTION_FORWARD
);
$event->handled = true;
} else {
$event->data = $this->render('quiz\question', compact('event', 'model', 't'));
}
}
public function actionQuiz($step = null)
{
//if ($step===null) $this->resetWizard();
return $this->step($step);
}
perhaps the page does not return if to output a variable $event->data , it contains the page code
Bag in $config['bootstrap'][] = 'debug'; Work, if comment debug
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
// $config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
// uncomment the following to add your IP if you are not connecting from localhost.
//'allowedIPs' => ['127.0.0.1', '::1'],
];
Temporal fix:
public function beforeAction($action) {
\yii\base\Event::off('*', '*');
return parent::beforeAction($action);
}
I would suggest not to disable all events, but to disable only "Event Panel" in debug panel.
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
'panels'=>[
'event'=>false,
]
];