mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 09:05:49 +00:00
FIX regression testing fixes
This commit is contained in:
parent
49610f2ce4
commit
34970c754f
@ -180,7 +180,7 @@ abstract class MultiForm extends Form
|
|||||||
// Disable security token - we tie a form to a session ID instead
|
// Disable security token - we tie a form to a session ID instead
|
||||||
$this->disableSecurityToken();
|
$this->disableSecurityToken();
|
||||||
|
|
||||||
$this->config()->merge('ignored_fields', $getVar);
|
$this->config()->merge('ignored_fields', [$getVar]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -220,7 +220,7 @@ abstract class MultiForm extends Form
|
|||||||
// Check if there was a start step defined on the subclass of MultiForm
|
// Check if there was a start step defined on the subclass of MultiForm
|
||||||
if (!isset($startStepClass)) {
|
if (!isset($startStepClass)) {
|
||||||
user_error(
|
user_error(
|
||||||
'MultiForm::init(): Please define a $start_step on ' . $this->class,
|
'MultiForm::init(): Please define a $start_step on ' . static::class,
|
||||||
E_USER_ERROR
|
E_USER_ERROR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -302,13 +302,9 @@ abstract class MultiForm extends Form
|
|||||||
|
|
||||||
// If there was no session found, create a new one instead
|
// If there was no session found, create a new one instead
|
||||||
if (!$this->session) {
|
if (!$this->session) {
|
||||||
$this->session = MultiFormSession::create();
|
$session = MultiFormSession::create();
|
||||||
}
|
$session->write();
|
||||||
|
$this->session = $session;
|
||||||
// Create encrypted identification to the session instance if it doesn't exist
|
|
||||||
if (!$this->session->Hash) {
|
|
||||||
$this->session->Hash = sha1($this->session->ID . '-' . microtime());
|
|
||||||
$this->session->write();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,30 +429,6 @@ abstract class MultiForm extends Form
|
|||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a rendered version of this form, with a specific template.
|
|
||||||
* Looks through the step ancestory templates (MultiFormStep, current step
|
|
||||||
* subclass template) to see if one is available to render the form with. If
|
|
||||||
* any of those don't exist, look for a default Form template to render
|
|
||||||
* with instead.
|
|
||||||
*
|
|
||||||
* @return SSViewer object to render the template with
|
|
||||||
*/
|
|
||||||
public function forTemplate()
|
|
||||||
{
|
|
||||||
$return = $this->renderWith([
|
|
||||||
$this->getCurrentStep()->class,
|
|
||||||
'MultiFormStep',
|
|
||||||
$this->class,
|
|
||||||
'MultiForm',
|
|
||||||
'Form'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->clearMessage();
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method saves the data on the final step, after submitting.
|
* This method saves the data on the final step, after submitting.
|
||||||
* It should always be overloaded with parent::finish($data, $form)
|
* It should always be overloaded with parent::finish($data, $form)
|
||||||
|
@ -78,4 +78,14 @@ class MultiFormSession extends DataObject
|
|||||||
|
|
||||||
parent::onBeforeDelete();
|
parent::onBeforeDelete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onAfterWrite()
|
||||||
|
{
|
||||||
|
parent::onAfterWrite();
|
||||||
|
// Create encrypted identification to the session instance if it doesn't exist
|
||||||
|
if (!$this->Hash) {
|
||||||
|
$this->Hash = sha1($this->ID . '-' . microtime());
|
||||||
|
$this->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ class MultiFormStep extends DataObject
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
protected static $can_go_back = true;
|
private static $can_go_back = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title of this step.
|
* Title of this step.
|
||||||
@ -249,7 +249,7 @@ class MultiFormStep extends DataObject
|
|||||||
if (!isset($nextSteps)) {
|
if (!isset($nextSteps)) {
|
||||||
user_error(
|
user_error(
|
||||||
'MultiFormStep->getNextStep(): Please define at least one $next_steps on '
|
'MultiFormStep->getNextStep(): Please define at least one $next_steps on '
|
||||||
. $this->class,
|
. static::class,
|
||||||
E_USER_ERROR
|
E_USER_ERROR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -314,8 +314,8 @@ class MultiFormStep extends DataObject
|
|||||||
$step->setForm($this->form);
|
$step->setForm($this->form);
|
||||||
|
|
||||||
if ($step->getNextStep()) {
|
if ($step->getNextStep()) {
|
||||||
if ($step->getNextStep() == $this->class) {
|
if ($step->getNextStep() == static::class) {
|
||||||
return $step->class;
|
return get_class($step);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ class MultiFormStep extends DataObject
|
|||||||
*/
|
*/
|
||||||
public function isCurrentStep()
|
public function isCurrentStep()
|
||||||
{
|
{
|
||||||
return ($this->class == $this->getSession()->CurrentStep()->class) ? true : false;
|
return (static::class == get_class($this->getSession()->CurrentStep())) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<% if $LinkingMode = current %>
|
<% if $LinkingMode = current %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if $ID %>
|
<% if $ID %>
|
||||||
<a href="{$Top.URLSegment}/?${Top.GetVar}={$SessionID}&StepID={$ID}">
|
<a href="{$Top.URLSegment}/?{$Top.GetVar}={$Session.Hash}&StepID={$ID}">
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
<p><%t SilverStripe\\MultiForm\\MultiForm.ProgressPercent "You've completed {percent}% ({completedSteps}/{totalSteps})" percent=$CompletedPercent.Nice completedSteps=$CompletedStepCount totalSteps$TotalStepCount %></p>
|
<p><%t SilverStripe\\MultiForm\\MultiForm.ProgressPercent "You've completed {percent}% ({completedSteps}/{totalSteps})" percent=$CompletedPercent.Nice completedSteps=$CompletedStepCount totalSteps=$TotalStepCount %></p>
|
||||||
|
@ -93,7 +93,7 @@ class MultiFormTest extends FunctionalTest
|
|||||||
public function testParentForm()
|
public function testParentForm()
|
||||||
{
|
{
|
||||||
$currentStep = $this->form->getCurrentStep();
|
$currentStep = $this->form->getCurrentStep();
|
||||||
$this->assertEquals($currentStep->getForm()->class, $this->form->class);
|
$this->assertEquals(get_class($currentStep->getForm()), get_class($this->form));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTotalStepCount()
|
public function testTotalStepCount()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user