public function next($data, $form)
    {
        // Save the form data for the current step
        $this->save($form->getData());

        // Get the next step class
        $nextStepClass = $this->getCurrentStep()->getNextStep();

        if (!$nextStepClass) {
            $this->controller->redirectBack();
            return false;
        }

        // Perform custom step validation (use MultiFormStep->getValidator() for
        // built-in functionality). The data needs to be manually saved on error
        // so the form is re-populated.
        if (!$this->getCurrentStep()->validateStep($data, $form)) {
            $this->getRequest()->getSession()->set("FormInfo.{$form->FormName()}.data", $form->getData());
            $this->controller->redirectBack();
            return false;
        }

        // validation succeeded so we reset it to remove errors and messages
        $this->clearFormState();

        // Determine whether we can use a step already in the DB, or have to create a new one
        if (!$nextStep = DataObject::get_one($nextStepClass, "\"SessionID\" = {$this->session->ID}")) {
            $nextStep = Injector::inst()->create($nextStepClass);
            $nextStep->SessionID = $this->session->ID;
            $nextStep->write();
        }

        // Set the next step found as the current step
        $this->setCurrentStep($nextStep);

        // Redirect to the next step
        $this->controller->redirect($nextStep->Link());
    }
public function next($data, $form)
    {
        // Save the form data for the current step
        $this->save($form->getData());

        // Get the next step class
        $nextStepClass = $this->getCurrentStep()->getNextStep();

        if (!$nextStepClass) {
            $this->controller->redirectBack();
            return false;
        }

        // Perform custom step validation (use MultiFormStep->getValidator() for
        // built-in functionality). The data needs to be manually saved on error
        // so the form is re-populated.
        if (!$this->getCurrentStep()->validateStep($data, $form)) {
            $this->getRequest()->getSession()->set("FormInfo.{$form->FormName()}.data", $form->getData());
            $this->controller->redirectBack();
            return false;
        }

        // validation succeeded so we reset it to remove errors and messages
        $this->clearFormState();

        // Determine whether we can use a step already in the DB, or have to create a new one
        if (!$nextStep = DataObject::get_one($nextStepClass, "\"SessionID\" = {$this->session->ID}")) {
            $nextStep = Injector::inst()->create($nextStepClass);
            $nextStep->SessionID = $this->session->ID;
            $nextStep->write();
        }

        // Set the next step found as the current step
        $this->setCurrentStep($nextStep);

        // Redirect to the next step
        $this->controller->redirect($nextStep->Link());
    }
public function next ( $ data , $ form ) { // Save the form data for the current step $ this -> save ( $ form -> getData ( ) ) ; // Get the next step class $ nextStepClass = $ this -> getCurrentStep ( ) -> getNextStep ( ) ; if ( ! $ nextStepClass ) { $ this -> controller -> redirectBack ( ) ; return false ; } // Perform custom step validation (use MultiFormStep->getValidator() for // built-in functionality). The data needs to be manually saved on error // so the form is re-populated. if ( ! $ this -> getCurrentStep ( ) -> validateStep ( $ data , $ form ) ) { $ this -> getRequest ( ) -> getSession ( ) -> set ( "FormInfo.{$form->FormName()}.data" , $ form -> getData ( ) ) ; $ this -> controller -> redirectBack ( ) ; return false ; } // validation succeeded so we reset it to remove errors and messages $ this -> clearFormState ( ) ; // Determine whether we can use a step already in the DB, or have to create a new one if ( ! $ nextStep = DataObject :: get_one ( $ nextStepClass , "\"SessionID\" = {$this->session->ID}" ) ) { $ nextStep = Injector :: inst ( ) -> create ( $ nextStepClass ) ; $ nextStep -> SessionID = $ this -> session -> ID ; $ nextStep -> write ( ) ; } // Set the next step found as the current step $ this -> setCurrentStep ( $ nextStep ) ; // Redirect to the next step $ this -> controller -> redirect ( $ nextStep -> Link ( ) ) ; }
Determine what to do when the next action is called.

Saves the current step session data to the database, creates the
new step based on getNextStep() of the current step (or fetches
an existing one), resets the current step to the next step,
then redirects to the newly set step.

@param array $data The request data returned from the form
@param Form $form The form that the action was called on
@return bool
Determine what to do when the next action is called .