mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
Made use of MultiFormStep::getNextStepFromDatabase() instead of direct DO::get() call, and check for SessionID before attempting a DO::get()
This commit is contained in:
parent
facf2e3833
commit
0d3196607a
@ -398,8 +398,7 @@ abstract class MultiForm extends Form {
|
|||||||
if(!$step->isFinalStep()) {
|
if(!$step->isFinalStep()) {
|
||||||
if($step->getNextStep()) {
|
if($step->getNextStep()) {
|
||||||
// Is this step in the DB? If it is, we use that
|
// Is this step in the DB? If it is, we use that
|
||||||
if($nextSteps = DataObject::get($step->getNextStep(), "SessionID = {$this->session->ID}", "LastEdited DESC")) {
|
if($nextStep = $step->getNextStepFromDatabase()) {
|
||||||
$nextStep = $nextSteps->First();
|
|
||||||
$templateData = array(
|
$templateData = array(
|
||||||
'ID' => $nextStep->ID,
|
'ID' => $nextStep->ID,
|
||||||
'ClassName' => $nextStep->class,
|
'ClassName' => $nextStep->class,
|
||||||
|
@ -152,23 +152,22 @@ class MultiFormStep extends DataObject {
|
|||||||
* Returns the next step to the current step in the database.
|
* Returns the next step to the current step in the database.
|
||||||
*
|
*
|
||||||
* This will only return something if you've previously visited
|
* This will only return something if you've previously visited
|
||||||
* the step ahead of the current step, so if you've gone to the
|
* the step ahead of the current step, and then gone back a step.
|
||||||
* step ahead, and then gone back a step.
|
|
||||||
*
|
*
|
||||||
* @return MultiFormStep|boolean
|
* @return MultiFormStep|boolean
|
||||||
*/
|
*/
|
||||||
public function getNextStepFromDatabase() {
|
public function getNextStepFromDatabase() {
|
||||||
|
if($this->SessionID) {
|
||||||
$nextSteps = $this->stat('next_steps');
|
$nextSteps = $this->stat('next_steps');
|
||||||
if(is_string($nextSteps)) {
|
if(is_string($nextSteps)) {
|
||||||
$step = DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
|
return DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
|
||||||
if($step) return $step;
|
|
||||||
} elseif(is_array($nextSteps)) {
|
} elseif(is_array($nextSteps)) {
|
||||||
$step = DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
|
return DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
|
||||||
if($step) return $step;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessor method for self::$next_steps
|
* Accessor method for self::$next_steps
|
||||||
|
Loading…
Reference in New Issue
Block a user