From 14b7c65859362f0cfee18d11d9ca14b363e4b2be Mon Sep 17 00:00:00 2001 From: muskie9 Date: Thu, 14 Jul 2016 09:29:25 -0500 Subject: [PATCH] BUGFIX progress bar button text change breaks buttons fixes #488 --- code/forms/UserForm.php | 8 ++++++++ code/model/UserDefinedForm.php | 1 + docs/en/installation.md | 11 ++++++++++- javascript/UserForm.js | 4 ++-- templates/Includes/UserFormProgress.ss | 2 +- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/forms/UserForm.php b/code/forms/UserForm.php index 2b69da5..09f4233 100644 --- a/code/forms/UserForm.php +++ b/code/forms/UserForm.php @@ -173,4 +173,12 @@ class UserForm extends Form { return $attrs; } + + /** + * @return string + */ + public function getButtonText() { + return $this->config()->get('button_text'); + } + } diff --git a/code/model/UserDefinedForm.php b/code/model/UserDefinedForm.php index 2592526..0edee64 100755 --- a/code/model/UserDefinedForm.php +++ b/code/model/UserDefinedForm.php @@ -311,6 +311,7 @@ SQL; public function getCMSValidator() { return new UserFormValidator(); } + } /** diff --git a/docs/en/installation.md b/docs/en/installation.md index d3a5600..23c3593 100644 --- a/docs/en/installation.md +++ b/docs/en/installation.md @@ -83,4 +83,13 @@ UserDefinedForm: email_template_directory: your/template/path/ ```` -Any SilverStripe templates placed in your `email_template_directory` directory will be available for use with submission emails. \ No newline at end of file +Any SilverStripe templates placed in your `email_template_directory` directory will be available for use with submission emails. + +### Custom Multi-Step button Text + +If you want to change the button text when using the Multi-Step/Page Break feature, simply add the following to your `config.yml`: + +```` +UserForm: + button_text: 'Your Text Here' +```` \ No newline at end of file diff --git a/javascript/UserForm.js b/javascript/UserForm.js index 5e7eac6..bab46a2 100644 --- a/javascript/UserForm.js +++ b/javascript/UserForm.js @@ -464,7 +464,7 @@ jQuery(function ($) { this.$buttons.each(function (i, stepButton) { $(stepButton).on('click', function (e) { e.preventDefault(); - self.$el.trigger('userform.progress.changestep', [parseInt($(this).text(), 10)]); + self.$el.trigger('userform.progress.changestep', [parseInt($(this).data('step'), 10)]); }); }); @@ -548,7 +548,7 @@ jQuery(function ($) { var $element = $(element), $item = $element.parent(); - if (parseInt($element.text(), 10) === stepNumber && $element.is(':visible')) { + if (parseInt($element.data('step'), 10) === stepNumber && $element.is(':visible')) { $item.addClass('current viewed'); $element.removeAttr('disabled'); diff --git a/templates/Includes/UserFormProgress.ss b/templates/Includes/UserFormProgress.ss index 0097ce3..0eebf13 100644 --- a/templates/Includes/UserFormProgress.ss +++ b/templates/Includes/UserFormProgress.ss @@ -9,7 +9,7 @@ <% loop $Steps %>
  • <%-- Remove js-align class to remove javascript positioning --%> - +
  • <% end_loop %>