Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Multiform skip step not working

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

Page: 1
Go to End
Author Topic: 1469 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Multiform skip step not working Link to this post

    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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Multiform skip step not working Link to this post

    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

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Multiform skip step not working Link to this post

    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

    1469 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.