我希望有人在计算器有向导行为扩展一些经验:http://www.yiiframework.com/extension/wizard-behavior/的Yii - 向导行为扩展 - 跳过步骤
的问题是,当我点击提交的第一页(用户)上,这是不言而喻的所有到结算页面的方式并跳过公司页面...帮助?
我有3个步骤来收集信息:用户,公司和结算页面。这里是我的行为功能在我的控制器:
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,
));
}
您是否可以发布您的_wizardUser($ event)方法,该方法可能有一些代码设置下一步计费。 – SuVeRa 2012-09-10 14:19:55
User中的代码与wizardCompany相同,只需用'user'和'$ company'替换'Company'和'$ user' – ews2001 2012-09-10 19:54:32