Merge pull request #3 from ajshort/master

Add Explicity Display Link Method
This commit is contained in:
Ingo Schommer 2011-12-20 02:57:22 -08:00
commit e95e751333
2 changed files with 30 additions and 2 deletions

View File

@ -75,7 +75,12 @@ abstract class MultiForm extends Form {
public static $actions_exempt_from_validation = array( public static $actions_exempt_from_validation = array(
'action_prev' 'action_prev'
); );
/**
* @var string
*/
protected $displayLink;
/** /**
* Start the MultiForm instance. * Start the MultiForm instance.
* *
@ -507,6 +512,29 @@ abstract class MultiForm extends Form {
return $action; 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 * Determine the steps to show in a linear fashion, starting from the
* first step. We run {@link getAllStepsRecursive} passing the steps found * first step. We run {@link getAllStepsRecursive} passing the steps found

View File

@ -126,7 +126,7 @@ class MultiFormStep extends DataObject {
* @return string Relative URL to this step * @return string Relative URL to this step
*/ */
public function Link() { public function Link() {
return Controller::curr()->Link() . '?MultiFormSessionID=' . $this->Session()->Hash; return Controller::join_links($this->form->getDisplayLink(), "?MultiFormSessionID={$this->Session()->Hash}");
} }
/** /**