From 60fa84df859ab0b9b5b345743d5efb7ae366f036 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 11 May 2010 03:27:42 +0000 Subject: [PATCH] ENHANCEMENT Custom text for back/next and submit buttons on a per-step basis (defaults to MultiForm.BACK, MultiForm.SUBMIT etc translatable entities) --- code/MultiForm.php | 8 ++++---- code/MultiFormStep.php | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/code/MultiForm.php b/code/MultiForm.php index c47695d..73c76a2 100644 --- a/code/MultiForm.php +++ b/code/MultiForm.php @@ -315,19 +315,19 @@ abstract class MultiForm extends Form { // If the form is at final step, create a submit button to perform final actions // The last step doesn't have a next button, so add that action to any step that isn't the final one if($step->isFinalStep()) { - $actions->push(new FormAction('finish', _t('MultiForm.SUBMIT', 'Submit'))); + $actions->push(new FormAction('finish', $step->getSubmitText())); } else { - $actions->push(new FormAction('next', _t('MultiForm.NEXT', 'Next'))); + $actions->push(new FormAction('next', $step->getNextText())); } // If there is a previous step defined, add the back button if($step->getPreviousStep() && $step->canGoBack()) { // If there is a next step, insert the action before the next action if($step->getNextStep()) { - $actions->insertBefore(new FormAction('prev', _t('MultiForm.BACK', 'Back')), 'action_next'); + $actions->insertBefore(new FormAction('prev', $step->getPrevText()), 'action_next'); // Assume that this is the last step, insert the action before the finish action } else { - $actions->insertBefore(new FormAction('prev', _t('MultiForm.BACK', 'Back')), 'action_finish'); + $actions->insertBefore(new FormAction('prev', $step->getPrevText()), 'action_finish'); } } diff --git a/code/MultiFormStep.php b/code/MultiFormStep.php index a181bee..0df28a4 100644 --- a/code/MultiFormStep.php +++ b/code/MultiFormStep.php @@ -284,7 +284,31 @@ class MultiFormStep extends DataObject { return DataObject::get_one($prevStepClass, "\"SessionID\" = {$this->SessionID}"); } } - + + /** + * Get the text to the use on the button to the previous step. + * @return string + */ + public function getPrevText() { + return _t('MultiForm.BACK', 'Back'); + } + + /** + * Get the text to use on the button to the next step. + * @return string + */ + public function getNextText() { + return _t('MultiForm.NEXT', 'Next'); + } + + /** + * Get the text to use on the button to submit the form. + * @return string + */ + public function getSubmitText() { + return _t('MultiForm.SUBMIT', 'Submit'); + } + /** * Sets the form that this step is directly related to. *