Yii Framework Forum

Wizard Behavior


(Chris) #1

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.

Links

  • Wizard Behavior Extension

  • Wizard Behavior demos

  • Wizard Behavior Manual


(Zamanfoo) #2

Thanks for sharing! Haven’t tried it yet but looking at the demos it seems very nice :)

+1


(tri - Tommy Riboe) #3

Looks like a great extension.

The demo will need some tweaking, for it to work from a subdirectory (instead of subdomain).




<li><a href="<?php echo $this->createUrl('/demo/registration'); ?>">Registration ...



I found these so far:

views/demo/index.php: example links

views/layouts/main.php: logo image and click

views/demo/quiz/completed.php: return link

Some problem with the survey wizard (cannot find pet.php)

Continuing… and and at the same time learning how to use the extension.

Thanks.

/Tommy


(Chris) #4

Please give more details; all the demos seem to be working just fine.


(tri - Tommy Riboe) #5

I added this line to views/demo/completed.php (line 4)


$step = ucfirst($step);

and was able to continue.

Also modified this line




echo CHtml::link('Choose Another Demo', $this->createUrl('/'));



/Tommy


(Mh) #6

Looks like a very cool extension, thanks!

Unfortunately i’m not very good at reading PDFs - do you think you could provide an online HTML version of the docs, too? ;)


(Antonio) #7

Thanks for sharing… btw, i couldn’t get out from the first step (something wrong with password validations)


(Mtc900) #8

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?

TIA,

dave


(Joe) #9

What’s the easiest way to display input results from previous steps to the user when he is working on a step?

How can I access the results of the previous steps?

For example - registration wizard demo:

I want to display the username / email from step1 at the top of the step2 form (Profile), and also on step3 …


(Jacob Moen) #10

Awesome extension!

Thanks a lot! :lol:

@Joblo:

Use WizardBehavior::read($step) to get the data for a particular step.


#11

who can help with this ext? here is the q. http://stackoverflow.com/questions/6043773/yii-cformmodel-dynamic-properties


(Jacob Moen) #12

Are you too lazy to post the question here??

((Because I am way too lazy to click a link…))


#13

i got such form


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?


(Chris) #14

use the read() method. read() will return data for all steps, read(stepName)will return data for the step stepName. See page 19 of the manual.


(Chris) #15

Use Plot Branching Navigation


(Asti Ramadhanie) #16

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.

  1. 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 (B) 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?

  2. 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.

Thanks and regards.


(Pirificio) #17

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!


(Sebastian Kather) #18

Hi guys,

it seems your online demo is currently not working:

http://wizard-behavior.pbm-webdev.co.uk/

BR

Sebastian


(Chris) #19

The demo is working again


(Chris) #20

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);