我希望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,
));
}