Merge remote-tracking branch 'origin/3.1'
# Conflicts: # code/forms/UserForm.php # code/model/UserDefinedForm.php # code/model/editableformfields/EditableFileField.php # code/model/editableformfields/EditableOption.php
This commit is contained in:
commit
c6c609a4c9
|
@ -33,17 +33,17 @@ class UserForm extends Form
|
|||
|
||||
// Number each page
|
||||
$stepNumber = 1;
|
||||
foreach ($this->getSteps() as $step) {
|
||||
foreach($this->getSteps() as $step) {
|
||||
$step->setStepNumber($stepNumber++);
|
||||
}
|
||||
|
||||
if ($controller->DisableCsrfSecurityToken) {
|
||||
if($controller->DisableCsrfSecurityToken) {
|
||||
$this->disableSecurityToken();
|
||||
}
|
||||
|
||||
$data = Session::get("FormInfo.{$this->FormName()}.data");
|
||||
|
||||
if (is_array($data)) {
|
||||
if(is_array($data)) {
|
||||
$this->loadDataFrom($data);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class UserForm extends Form
|
|||
*/
|
||||
public function getSteps()
|
||||
{
|
||||
return $this->Fields()->filterByCallback(function ($field) {
|
||||
return $this->Fields()->filterByCallback(function($field) {
|
||||
return $field instanceof UserFormsStepField;
|
||||
});
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class UserForm extends Form
|
|||
new FormAction("process", $submitText)
|
||||
);
|
||||
|
||||
if ($this->controller->ShowClearButton) {
|
||||
if($this->controller->ShowClearButton) {
|
||||
$actions->push(new ResetFormAction("clearForm", $clearText));
|
||||
}
|
||||
|
||||
|
@ -174,4 +174,12 @@ class UserForm extends Form
|
|||
|
||||
return $attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getButtonText() {
|
||||
return $this->config()->get('button_text');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class EditableOption extends DataObject
|
|||
{
|
||||
// Check parent page
|
||||
$parent = $this->getCanCreateContext(func_get_args());
|
||||
if ($parent) {
|
||||
if($parent) {
|
||||
return $parent->canEdit($member);
|
||||
}
|
||||
|
||||
|
@ -117,11 +117,11 @@ class EditableOption extends DataObject
|
|||
protected function getCanCreateContext($args)
|
||||
{
|
||||
// Inspect second parameter to canCreate for a 'Parent' context
|
||||
if (isset($args[1]['Parent'])) {
|
||||
if(isset($args[1]['Parent'])) {
|
||||
return $args[1]['Parent'];
|
||||
}
|
||||
// Hack in currently edited page if context is missing
|
||||
if (Controller::has_curr() && Controller::curr() instanceof CMSMain) {
|
||||
if(Controller::has_curr() && Controller::curr() instanceof CMSMain) {
|
||||
return Controller::curr()->currentPage();
|
||||
}
|
||||
|
||||
|
@ -161,4 +161,12 @@ class EditableOption extends DataObject
|
|||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
protected function onBeforeWrite() {
|
||||
if (!$this->Sort) {
|
||||
$this->Sort = EditableOption::get()->max('Sort') + 1;
|
||||
}
|
||||
|
||||
parent::onBeforeWrite();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,3 +84,12 @@ UserDefinedForm:
|
|||
````
|
||||
|
||||
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'
|
||||
````
|
|
@ -468,7 +468,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)]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -552,7 +552,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');
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<% loop $Steps %>
|
||||
<li class="step-button-wrapper<% if $First %> current<% end_if %>" data-for="$Name">
|
||||
<%-- Remove js-align class to remove javascript positioning --%>
|
||||
<button class="step-button-jump js-align" disabled="disabled">$Pos</button>
|
||||
<button class="step-button-jump js-align" disabled="disabled" data-step="$Pos"><% if $Top.ButtonText %>$Top.ButtonText <% end_if %>$Pos</button>
|
||||
</li>
|
||||
<% end_loop %>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue