mirror of
https://github.com/silverstripe/silverstripe-multiform
synced 2024-10-22 09:05:49 +00:00
ENHANCEMENT Custom text for back/next and submit buttons on a per-step basis (defaults to MultiForm.BACK, MultiForm.SUBMIT etc translatable entities)
This commit is contained in:
parent
b84fae26a3
commit
60fa84df85
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user