Wizard Behavior is an extension that simplifies the handling of multi-step forms. It features data persistence, Plot-Branching Navigation (PBN), Next/Previous or Forward Only navigation, optional step timeout, invalid step handling, save and recover wizards between sessions, and has utility methods for use in views to assist navigation.
The demos demonstrate these features (the code can be downloaded from the extension’s page).
The manual fully documents the API, gives details on useage and contains example code.
I hope you find it useful for your project.
If you have any comments, bug reports, or suggestions please add them to this thread.
This extension is extremely helpful in my development. However, I would like to provide multiple links or buttons to replace the "next" (submit) button instead of having the user select a choice with a checkbox or similar. For example, say during a registration process you must select a type of product. Having the list and descriptions of the product types and a link next to each I would like the wizard to pick up at the next step with that information. Does anyone have an idea how to make that happen with the Wizard Behavior?
class CC extends CFormModel
{
public $static_field;
public $fields;
public function rules()
{
return array(
array('static_field, testF', 'required')
);
}
public function getForm()
{
return new CForm(array(
'showErrorSummary'=>true,
'elements'=>array(
'static_field'=>array(),
'testF'=>array(),
),
'buttons'=>array(
'submit'=>array(
'type'=>'submit',
'label'=>'Next'
)
)
), $this);
}
public function attributeLabels()
{
return array(
'static_field' => 'static_field'
);
}
public function __get($name)
{
if (isset($this->fields[$name]))
return $this->fields[$name];
else
return '';
}
public function __set($name, $value)
{
$this->fields[$name] = $value;
}
}
i want to add dynamical field testF
i try to use __get\__set and array for values, but nothing work. any ideas?
Hello guys, i am a newbie in yii and now i’m trying to implement a wizard behavior in my application.
I have some questions about this ext, maybe you can help me with these.
Let say I have two forms, A and B. Form B has a field which is a foreign key from A. The field exists on both forms, but the input process should be done in form A. And in the next form ( the field has to be shown again with the value that automatically retrieved from A. How could I do this? How to retrieve a particular value from the previous step?
The demo just display the complete result of all process. How is the way to store those data in permanent storage (database)?
I’ll be very grateful if anyone could give me the solution.
HI there. I was wondering this myself for a long time. Here is what I did. Now assuming that I am only using the wizard for creating records, here is my controller:
/**
* The wizard has finished; use $event->step to find out why.
* Normally on successful completion ($event->step===true) data would be saved
* to permanent storage; the demo just displays it
* @param WizardEvent The event
*/
public function wizardFinished($event) {
$command = Yii::app()->db->createCommand();
if(isset($event->data['UserEmployeeProfile'])){
$db_array = merge_array($event->data['User'],$event->data['ContactDetails'],$event->data['UserEmployeeProfile'],$event->data['UploadPhoto']);
}else{
$db_array = array_merge($event->data['User'],$event->data['ContactDetails'],$event->data['UserEmployerProfile'],$event->data['UploadPhoto']);
}
if ($event->step===true){
$command->insert('users',$db_array);
// ...redirect to another page
$this->render('completed', compact('event'));
}else{
$this->render('finished', compact('event'));
}
$event->sender->reset();
Yii::app()->end();
}
I had to test to see if UserEmployeeProfile or UserEmployerProfile was set because my wizard uses branching. Hope this helps!
You simply read the data from the wizard with $wizard->read($step) - $step is optional and if empty returns all steps currently stored. Inside an event handler $wizard === $event->sender - so you would do $event->sender->read($step);