我希望stackoverflow上的人有一些使用向导行为扩展的经验:http://www.yiiframework.com/extension/wizard-behavior/
问题是,当我单击第一页(用户)上的提交时,它会一直跳到计费页面,并跳过公司的page...help?
我有3个步骤来收集信息:用户,公司和帐单页面。下面是我的控制器中的behaviors函数:
public function behaviors() {
return array(
'wizard'=>array(
'class'=>'ext.WizardBehavior.WizardBehavior',
'steps'=>array(
'user','company','billing'
)
)
)
}这是我的流程步骤函数:
public function wizardProcessStep($event) {
$name = '_wizard'.ucfirst($event->step);
if (method_exists($this, $name)) {
call_user_func(array($this,$name), $event);
} else {
throw new CException(Yii::t('yii','{class} does not have a method named "{name}"', array('{class}'=>get_class($this), '{name}'=>$name)));
}
}以下是我的公司步骤作为示例:
protected function _wizardCompany($event) {
echo 'called company';
exit();
$company=new Company;
if(isset($_POST['Company'])) {
$company->attributes=$_POST['Company'];
if($company->validate()) {
$event->sender->save($company->attributes);
$event->handled = true;
}
}
$this->render('new_company',array(
'company'=>$company,
'event'=>$event,
));
}发布于 2012-09-13 22:41:54
这似乎不是一个bug,而是设计出来的。默认情况下,WizardBehavior跳到第一个未处理的步骤。
您可能正在测试向导,并在"User“和"Company”中输入了某些内容。当您现在在“帐单”,并返回到“用户”(通过url或链接)。输入某些内容并再次提交,它将跳到计费,因为这是第一个未处理的步骤。请注意,您可以通过URL和链接转到"Company“和所有之前处理过的步骤。
可以通过以下方式将此行为设置为false
public function behaviors() {
return array(
'wizard'=>array(
'autoAdvance' => false,
)
)
}或者实现onFinish事件,以便在测试时轻松重置向导。
https://stackoverflow.com/questions/11583680
复制相似问题