【发布时间】:2012-07-20 16:46:40
【问题描述】:
我希望 stackoverflow 上的人对向导行为扩展有一些经验:http://www.yiiframework.com/extension/wizard-behavior/
问题是当我在第一页(用户)上点击提交时,它一直到帐单页面并跳过公司页面...帮助?
我有 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) 方法,该方法可能包含一些设置下一步计费的代码。
-
User中的代码与wizardCompany相同,只需将
Company替换为User和$company替换为$user
标签: yii wizard yii-extensions