Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FormFlow.php #235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Form/FormFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ abstract class FormFlow implements FormFlowInterface {
*/
private $expired = false;


/**
* Flow was determined to be expired on post.
* @var boolean
*/
private $expiresOnRequest = true;

/**
* Instance ID was a newly generated ID.
* @var boolean
Expand Down Expand Up @@ -639,7 +646,7 @@ protected function bindFlow() {
$reset = true;
}

if (in_array($this->getRequest()->getMethod(), array('POST', 'PUT')) && !$this->dataManager->exists($this)) {
if ($this->expiresOnRequest && (in_array($this->getRequest()->getMethod(), array('POST', 'PUT')) && !$this->dataManager->exists($this))) {
// flow is expired, drop posted data and reset
$this->getRequest()->request->replace();
$reset = true;
Expand Down Expand Up @@ -972,6 +979,14 @@ public function createStepsFromConfig(array $stepsConfig) {
return $steps;
}

/**
* @param $expires
*/
public function expiresOnRequest($expires)
{
$this->expiresOnRequest = $expires;
}

/**
* Defines the configuration for all steps of this flow.
* @return array
Expand Down
5 changes: 5 additions & 0 deletions Form/FormFlowInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,9 @@ function getSteps();
*/
function getStepCount();

/**
* Toggles expiration on request
* @param $expires
*/
function expiresOnRequest($expires);
}