mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 11:05:49 +02:00
Merge pull request #3 from ajshort/master
Add Explicity Display Link Method
This commit is contained in:
commit
e95e751333
@ -75,7 +75,12 @@ abstract class MultiForm extends Form {
|
||||
public static $actions_exempt_from_validation = array(
|
||||
'action_prev'
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $displayLink;
|
||||
|
||||
/**
|
||||
* Start the MultiForm instance.
|
||||
*
|
||||
@ -507,6 +512,29 @@ abstract class MultiForm extends Form {
|
||||
return $action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the link to the page where the form is displayed. The user is
|
||||
* redirected to this link with a session param after each step is
|
||||
* submitted.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayLink() {
|
||||
return $this->displayLink ? $this->displayLink : Controller::curr()->Link();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the link to the page on which the form is displayed.
|
||||
*
|
||||
* The link defaults to the controllers current link. However if the form
|
||||
* is displayed inside an action the display link must be explicitly set.
|
||||
*
|
||||
* @param string $link
|
||||
*/
|
||||
public function setDisplayLink($link) {
|
||||
$this->displayLink = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the steps to show in a linear fashion, starting from the
|
||||
* first step. We run {@link getAllStepsRecursive} passing the steps found
|
||||
|
@ -126,7 +126,7 @@ class MultiFormStep extends DataObject {
|
||||
* @return string Relative URL to this step
|
||||
*/
|
||||
public function Link() {
|
||||
return Controller::curr()->Link() . '?MultiFormSessionID=' . $this->Session()->Hash;
|
||||
return Controller::join_links($this->form->getDisplayLink(), "?MultiFormSessionID={$this->Session()->Hash}");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user