Yii Framework Forum: Wizard Behavior - Yii Framework Forum

Jump to content

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4
  • You cannot start a new topic
  • You cannot reply to this topic

Wizard Behavior Multi-step form handling Rate Topic: ***** 4 Votes

#61 User is offline   Marnick 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-April 14

Posted 18 April 2014 - 07:54 AM

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

0

#62 User is offline   kpapageorgiou 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 27-February 14

Posted 23 May 2014 - 12:21 PM

View Postrussellfeeed, on 19 September 2011 - 12:45 PM, said:

And another newbie question....

can I loop back to a previous step.

I want a wizard that says

Step 1. How many serial numbers do you want to enter [......] <- e.g. user enters 10.
Step 2. Enter your serial number [.........]

Then it loops back to 2 again, doing so ten times.

Cheers
Russell


Hi guys,
is this question answered somehow?

Thank you for your time
0

#63 User is offline   paskuale 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 395
  • Joined: 30-December 11
  • Location:Italy, Bari

Posted 30 August 2014 - 02:56 AM

Anyone has a CMenu sample for wizardBehavior object ?

thanks
0

#64 User is offline   paskuale 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 395
  • Joined: 30-December 11
  • Location:Italy, Bari

Posted 30 August 2014 - 04:34 AM

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

thanks
0

#65 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 10-February 12

Posted 08 September 2014 - 03:16 AM

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

0

Share this topic:


  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users