Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Multiform skip step not working


Reply


3 Posts   1487 Views

Avatar
Harley

Community Member, 153 Posts

12 April 2010 at 12:29am

Edited: 12/04/2010 12:31am

Hi, I've posted about this before but never had a definitive answer and was hoping someone could help me get to the bottom of this.

I'm stuck on trying to get a multiform to skip a step, I have tried setting up an SS site using version 2.3.4 as a test area and building a brand new multiform and adding in the conditional statements to skip steps and I'm having no joy what so ever.

I have set up four steps with drop downs in each form so I can select which step to jump to.

I've tried using two methods to achieve this as seen in the documentation http://doc.silverstripe.org/doku.php?id=modules:multiform#getnextstep and http://doc.silverstripe.org/doku.php?id=modules:multiform&rev=1209417500#getnextstep:

class MyStep extends MultiFormStep

// ...

public function getNextStep() {
if($this->loadData()->Condition) {
return 'TestThirdCase1Step';
} else {
return 'TestThirdCase2Step';
}
}

// ...

}

and

class MyStep extends MultiFormStep

// ...

public function getNextStep() {
$data = $this->loadData();
if($data['Gender'] == 'Male') {
return 'TestThirdCase1Step';
} else {
return 'TestThirdCase2Step';
}
}

// ...

Here is my code so far for the part where I want to skip the next step:

<?php

class FirstStep extends MultiFormStep{
   
   protected $title = 'First Step';
//   protected static $next_steps = 'SecondStep';

   function getFields(){
      $fields = singleton('First')->getFrontEndFields();
      return $fields;
   }

   public function getNextStep(){
   
   $data = $this->loadData();
   $option = $data['DropDownOne'];

      if($option == 'OptionThree'){
            return 'ThirdStep';
         } else {
            return 'SecondStep';
      }
   }
}

?>

If it helps anyone to know, when I go to the next step after selecting 'option three' the back button disappears.

Thanks

Avatar
Harley

Community Member, 153 Posts

12 April 2010 at 12:43am

Just figured something out,

  • if on the first step I choose 'option three' it takes me to the second step but looses the back button.
  • If I hit next it takes me to the third step which has a back button.
  • If I then click back it takes me to step one, and if I click next it takes me to step three and so on.

So to conclude that, after selecting 'option three' in step one and then on step two I have clicked next, the form behaves correctly, sort of.

Hope that sheds some more light on this. I'm probably doing something silly here but all the code seems fine according to the documentation.

Cheers

Avatar
Harley

Community Member, 153 Posts

26 April 2010 at 10:45am

Sorry to regurgitate this one but does anyone have any idea why my skipping a step will not work?

I'm really stuck on this one and desperately need some help or a push in the right direction.

Any responses are greatly appreciated

Thanks