Wizard Behavior

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(

                'label'=>$this->menuLastItem,

                'active'=>false

            );

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

    }



Hi guys,

is this question answered somehow?

Thank you for your time

Anyone has a CMenu sample for wizardBehavior object ?

thanks

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

thanks

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

            Yii::log(json_encode($event->data),'error');

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

   			}

     			

		}

		else

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


		$event->sender->reset();

		Yii::app()->end();

	}

Hi,

You have to use following code

To get primarykey of model

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

To get last saved ID

$model->save();

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

[size=2]

[/size]

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

Hi

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?

Thanks

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!

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.

Two minutes of searchingā€¦

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

1 Like