public function getCurrentStep()
    {
        $startStepClass = $this->config()->get('start_step');

        // Check if there was a start step defined on the subclass of MultiForm
        if (!isset($startStepClass)) {
            user_error(
                'MultiForm::init(): Please define a $start_step on ' . static::class,
                E_USER_ERROR
            );
        }

        // Determine whether we use the current step, or create one if it doesn't exist
        $currentStep = null;
        $StepID = $this->controller->getRequest()->getVar('StepID');
        if (isset($StepID)) {
            $currentStep = DataObject::get_one(
                MultiFormStep::class,
                [
                    'SessionID' => $this->session->ID,
                    'ID' => $StepID
                ]
            );
        } elseif ($this->session->CurrentStepID) {
            $currentStep = $this->session->CurrentStep();
        }

        // Always fall back to creating a new step (in case the session or request data is invalid)
        if (!$currentStep || !$currentStep->ID) {
            $currentStep = Injector::inst()->create($startStepClass);
            $currentStep->SessionID = $this->session->ID;
            $currentStep->write();
            $this->session->CurrentStepID = $currentStep->ID;
            $this->session->write();
            $this->session->flushCache();
        }

        if ($currentStep) {
            $currentStep->setForm($this);
        }

        return $currentStep;
    }
public function getCurrentStep()
    {
        $startStepClass = $this->config()->get('start_step');

        // Check if there was a start step defined on the subclass of MultiForm
        if (!isset($startStepClass)) {
            user_error(
                'MultiForm::init(): Please define a $start_step on ' . static::class,
                E_USER_ERROR
            );
        }

        // Determine whether we use the current step, or create one if it doesn't exist
        $currentStep = null;
        $StepID = $this->controller->getRequest()->getVar('StepID');
        if (isset($StepID)) {
            $currentStep = DataObject::get_one(
                MultiFormStep::class,
                [
                    'SessionID' => $this->session->ID,
                    'ID' => $StepID
                ]
            );
        } elseif ($this->session->CurrentStepID) {
            $currentStep = $this->session->CurrentStep();
        }

        // Always fall back to creating a new step (in case the session or request data is invalid)
        if (!$currentStep || !$currentStep->ID) {
            $currentStep = Injector::inst()->create($startStepClass);
            $currentStep->SessionID = $this->session->ID;
            $currentStep->write();
            $this->session->CurrentStepID = $currentStep->ID;
            $this->session->write();
            $this->session->flushCache();
        }

        if ($currentStep) {
            $currentStep->setForm($this);
        }

        return $currentStep;
    }
public function getCurrentStep ( ) { $ startStepClass = $ this -> config ( ) -> get ( 'start_step' ) ; // Check if there was a start step defined on the subclass of MultiForm if ( ! isset ( $ startStepClass ) ) { user_error ( 'MultiForm::init(): Please define a $start_step on ' . static :: class , E_USER_ERROR ) ; } // Determine whether we use the current step, or create one if it doesn't exist $ currentStep = null ; $ StepID = $ this -> controller -> getRequest ( ) -> getVar ( 'StepID' ) ; if ( isset ( $ StepID ) ) { $ currentStep = DataObject :: get_one ( MultiFormStep :: class , [ 'SessionID' => $ this -> session -> ID , 'ID' => $ StepID ] ) ; } elseif ( $ this -> session -> CurrentStepID ) { $ currentStep = $ this -> session -> CurrentStep ( ) ; } // Always fall back to creating a new step (in case the session or request data is invalid) if ( ! $ currentStep || ! $ currentStep -> ID ) { $ currentStep = Injector :: inst ( ) -> create ( $ startStepClass ) ; $ currentStep -> SessionID = $ this -> session -> ID ; $ currentStep -> write ( ) ; $ this -> session -> CurrentStepID = $ currentStep -> ID ; $ this -> session -> write ( ) ; $ this -> session -> flushCache ( ) ; } if ( $ currentStep ) { $ currentStep -> setForm ( $ this ) ; } return $ currentStep ; }
Get the current step.

If StepID has been set in the URL, we attempt to get that record
by the ID. Otherwise, we check if there's a current step ID in
our session record. Failing those cases, we assume that the form has
just been started, and so we create the first step and return it.

@return MultiFormStep subclass
Get the current step .