(function ntSaveForms() {
var text, cl;
$(".ntSaveForms").each(function(i) {
cl = "ntSaveForms"+i;
$(this).addClass(cl); // add new class
text = $.Storage.get(cl);
if (text && text.length > 0 && !$(this).val()) {
$(this).val(text); // set field data
}
});
$(".ntSaveForms").keyup(function() {
$.Storage.set($(this).attr("class").split(" ")[$(this).attr("class").split(" ").length -1], $(this).val()); // save field data
});
$(".ntSaveFormsSubmit").click(function() {
$(".ntSaveForms").each(function(i) {
$.Storage.remove("ntSaveForms"+i); // remove data
});
});
})();
class User extends ActiveRecord
{
const SCENARIO_STEP1 = 'step1';
const SCENARIO_STEP2 = 'step2';
...
public function scenarios()
{
return [
self::SCENARIO_STEP1 => ['attr1', 'attr2'],
self::SCENARIO_STEP2 => ['attr3', 'attr4', 'attr5'],
];
}
...
public function actionStep1()
{
$model = new OrderWizard();
$model->setScenario(OrderWizard::SCENARIO_STEP1);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['step-2', 'id' => $model->id]);
} else {
return $this->render('step-1', [
'model' => $model,
]);
}
}