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->getNextStep()) {
|
||||
// Is this step in the DB? If it is, we use that
|
||||
if($nextSteps = DataObject::get($step->getNextStep(), "SessionID = {$this->session->ID}", "LastEdited DESC")) {
|
||||
$nextStep = $nextSteps->First();
|
||||
if($nextStep = $step->getNextStepFromDatabase()) {
|
||||
$templateData = array(
|
||||
'ID' => $nextStep->ID,
|
||||
'ClassName' => $nextStep->class,
|
||||
|
@ -152,21 +152,20 @@ class MultiFormStep extends DataObject {
|
||||
* Returns the next step to the current step in the database.
|
||||
*
|
||||
* This will only return something if you've previously visited
|
||||
* the step ahead of the current step, so if you've gone to the
|
||||
* step ahead, and then gone back a step.
|
||||
* the step ahead of the current step, and then gone back a step.
|
||||
*
|
||||
* @return MultiFormStep|boolean
|
||||
*/
|
||||
public function getNextStepFromDatabase() {
|
||||
$nextSteps = $this->stat('next_steps');
|
||||
if(is_string($nextSteps)) {
|
||||
$step = DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
|
||||
if($step) return $step;
|
||||
} elseif(is_array($nextSteps)) {
|
||||
$step = DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
|
||||
if($step) return $step;
|
||||
} else {
|
||||
return false;
|
||||
if($this->SessionID) {
|
||||
$nextSteps = $this->stat('next_steps');
|
||||
if(is_string($nextSteps)) {
|
||||
return DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
|
||||
} elseif(is_array($nextSteps)) {
|
||||
return DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user