diff --git a/wire/modules/Inputfield/InputfieldSubmit/InputfieldSubmit.module b/wire/modules/Inputfield/InputfieldSubmit/InputfieldSubmit.module
index 1c3f8802..2088e75a 100644
--- a/wire/modules/Inputfield/InputfieldSubmit/InputfieldSubmit.module
+++ b/wire/modules/Inputfield/InputfieldSubmit/InputfieldSubmit.module
@@ -3,7 +3,7 @@
/**
* An Inputfield for handling "submit" buttons
*
- * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
+ * ProcessWire 3.x, Copyright 2019 by Ryan Cramer
* https://processwire.com
* License: MPL 2.0
*
@@ -12,6 +12,11 @@
* @property bool $small Whether or not button should be small, where supported (default=false).
* @property string $dropdownInputName Name of input to receive selected dropdown value (default='_action_value') #pw-internal
* @property bool $dropdownSubmit Selected dropdown value becomes submit value? (default=true) #pw-internal
+ * @property string $html Button inner HTML label (default='') @since 3.0.134
+ * @property string $text Button inner TEXT label, if $html not provided. (default='') @since 3.0.134
+ * @property string $value Button value attribute and inner TEXT label, if $text it provided (default='Submit')
+ * @property string $textClass Class applied to span for inner html/text, omitted if blank (default='ui-button-text') @since 3.0.134
+ * @property-read string|false $submitValue Value that was submitted if clicked (default=false) @since 3.0.134
*
*/
class InputfieldSubmit extends Inputfield {
@@ -50,9 +55,13 @@ class InputfieldSubmit extends Inputfield {
$this->attr('type', 'submit');
$this->attr('name', 'submit');
$this->attr('value', $this->_('Submit')); // Standard submit button label
+ $this->set('submitValue', false); // becomes string after processInput
$this->attr('class', 'ui-button ui-widget ui-state-default ui-corner-all');
+ $this->set('textClass', 'ui-button-text');
$this->skipLabel = Inputfield::skipLabelBlank;
$this->set('small', false);
+ $this->set('html', '');
+ $this->set('text', '');
// name of 'hidden' input that will receive the clicked dropdown item value
$this->set('dropdownInputName', '_action_value');
@@ -160,10 +169,18 @@ class InputfieldSubmit extends Inputfield {
*/
public function ___render() {
$attrs = $this->getAttributesString();
- $icon = $this->icon ? $this->sanitizer->name($this->icon) : '';
- $icon = $icon ? " " : '';
- $value = $this->entityEncode($this->attr('value'));
- $out = "";
+ $icon = $this->icon ? $this->wire('sanitizer')->name($this->icon) : '';
+ $icon = $icon ? wireIconMarkup($icon) . ' ' : '';
+ $buttonText = $this->getSetting('html'); // option for non-encoded button text
+ if(empty($buttonText)) {
+ $buttonText = $this->getSetting('text');
+ if(empty($buttonText)) $buttonText = $this->attr('value');
+ $buttonText = $this->entityEncode($buttonText);
+ }
+ $buttonText = $icon . $buttonText;
+ $textClass = $this->wire('sanitizer')->entities($this->getSetting('textClass'));
+ if(!empty($textClass)) $buttonText = "$buttonText";
+ $out = "";
if($this->getSetting('small')) $out = "$out";
if(count($this->dropdownItems)) $out .= $this->renderDropdown();
return $out;
@@ -235,7 +252,31 @@ class InputfieldSubmit extends Inputfield {
*
*/
public function ___processInput(WireInputData $input) {
- // submit buttons don't need to process any input
+
+ $this->submitValue = '';
+ $name = $this->attr('name');
+ $value = $input->$name;
+
+ if($value === $this->attr('value')) {
+ $this->submitValue = $value;
+ return $this;
+ }
+
+ if(!count($this->dropdownItems)) return $this;
+
+ if(!$this->dropdownSubmit) {
+ $name = $this->dropdownInputName;
+ $value = $input->$name;
+ }
+
+ if($value === null) return $this;
+
+ foreach($this->dropdownItems as $item) {
+ if($value !== $item['value']) continue;
+ $this->submitValue = $item['value'];
+ break;
+ }
+
return $this;
}