Yii Framework Forum

Wizard Behavior

(Yii) #61

Great extension! I made some changes to the menu, so after users go backward in steps, they can also go forward again using the menu. I made the following changes:

insert after line 66: public $forwardOnly = false;


     * @property boolean If true, the user will be able to go forward to any step

     * that was already completed, plus the next incomplete one.


    public $forwardActive = true;

And replace the whole function generateMenuItems() starting on line 349 with:

    private function generateMenuItems() {

        $previous = true;

        $items = array();

        $url = array($this->owner->id.'/'.$this->getOwner()->getAction()->getId());

        $expectedIndex = $this->_steps->indexOf($this->getExpectedStep());

        // We should not have a url for later steps

        // We should not have a url for earlier steps if forwards only

        foreach ($this->_steps as $step) {

            $item = array();

            $item['label'] = $this->getStepLabel($step);

            $item['active'] = $step===$this->_currentStep;

            if (!$item['active'] && $previous && !empty($this->menuProperties['previousItemCssClass']))

                $item['itemOptions'] = array('class'=>$this->menuProperties['previousItemCssClass']);

            if (($previous && !$this->forwardOnly) || ($step===$this->_currentStep)) {

                $item['url'] = $url + array($this->queryParam=>$step);

                if ((!$this->forwardActive && $step===$this->_currentStep) OR

                    ($this->forwardActive && $this->_steps->indexOf($step)===$expectedIndex+1))

                    $previous = false;


            $items[] = $item;


        if (!empty($this->menuLastItem))

            $items[] = array(




        $this->_menu->items = $items;


(Kpapageorgiou) #62

Hi guys,

is this question answered somehow?

Thank you for your time

(Pellicanipasquale) #63

Anyone has a CMenu sample for wizardBehavior object ?


(Pellicanipasquale) #64

@Marnick great your menu upgrade, but with three steps, I’ve only first two item with <a href=""> the last without, why ?


(Redhen 07) #65

i have user and profile table

profile table is related from user table by user_id

my question is how can i get user id to be populated on my profile user_id when the wizard is Finished below is my code…

i only have error on my user_id

	public function wizardFinished($event) {

		if ($event->step===true){

			//save data to database


            $user = new User();

            $profile = new Profile();

            $user->username = $event->data['user']['username'];

            $user->password = $event->data['user']['password'];

            $user->email = $event->data['user']['email'];

            [b]$profile->user_id = $event->data['profile']['user_id'];[/b] //how can i get the id from user table

            $profile->lname = $event->data['profile']['lname'];

            $profile->fname = $event->data['profile']['fname'];

   			if($user->save() && $profile->save()){

   				$this->render('completed', compact('event'));





			$this->render('finished', compact('event'));




(Chandrantwins) #66


You have to use following code

To get primarykey of model

$primaryKey = $model->tableSchema->primaryKey;

To get last saved ID


[size=2]$previousid = $model->$primaryKey;[/size]



[size=2]save both primarykey and previousid before foreach…then you will get every model primary key and value after one another :)[/size]

(Astralliquid) #67


I need to do multi step in yii2

Can someone guide me how to get this done in yii2 with this plugin or other ways?


(Tstkenny) #68

Sorry to bump up this thread… I’ve been googling for days but unable to find a working sample for Yii2. Anyone kind enough to lend a hand please? My final goal is to integrate this with Dynamic Form Widget.

Thank you!

(Senguttuvang) #69

Demo and documentation links are down. Can anyone upload the pdf document, if you have a copy? I thought to use its yii2 port, but couldn’t find the documentation on how to use it.

(Andrzej1 1) #70

Two minutes of searching…

(Jeremy Kastner) #71

Links in this post are dead, link to the manual on the official site is dead, I can’t find the documentation for this plugin anymore. Anyone have it?

EDIT: Here it is: http://saadtrust.com/event/6977-wizard_behavior_manual.pdf