From c6918b77e1e0e2e38572934ecfe38f32553fd83e Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 21 Dec 2020 19:17:20 +0100 Subject: [PATCH] Add input mode support for `AbstractNumericFormField` --- com.woltlab.wcf/templates/__numericFormField.tpl | 1 + .../files/acp/templates/__numericFormField.tpl | 1 + .../field/AbstractNumericFormField.class.php | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/__numericFormField.tpl b/com.woltlab.wcf/templates/__numericFormField.tpl index 40baa2a2d1..f180b72d62 100644 --- a/com.woltlab.wcf/templates/__numericFormField.tpl +++ b/com.woltlab.wcf/templates/__numericFormField.tpl @@ -14,6 +14,7 @@ *}{if $field->isImmutable()} disabled{/if}{* *}{if $field->getMinimum() !== null} min="{$field->getMinimum()}"{/if}{* *}{if $field->getMaximum() !== null} max="{$field->getMaximum()}"{/if}{* + *}{if $field->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{* *}{if $field->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{* *}{if $field->getDocument()->isAjax()} data-dialog-submit-on-enter="true"{/if}{* *}> diff --git a/wcfsetup/install/files/acp/templates/__numericFormField.tpl b/wcfsetup/install/files/acp/templates/__numericFormField.tpl index 40baa2a2d1..f180b72d62 100644 --- a/wcfsetup/install/files/acp/templates/__numericFormField.tpl +++ b/wcfsetup/install/files/acp/templates/__numericFormField.tpl @@ -14,6 +14,7 @@ *}{if $field->isImmutable()} disabled{/if}{* *}{if $field->getMinimum() !== null} min="{$field->getMinimum()}"{/if}{* *}{if $field->getMaximum() !== null} max="{$field->getMaximum()}"{/if}{* + *}{if $field->getInputMode() !== null} inputmode="{$field->getInputMode()}"{/if}{* *}{if $field->getPlaceholder() !== null} placeholder="{$field->getPlaceholder()}"{/if}{* *}{if $field->getDocument()->isAjax()} data-dialog-submit-on-enter="true"{/if}{* *}> diff --git a/wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php index e366f0ae64..6e09e40390 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php @@ -11,11 +11,12 @@ use wcf\system\form\builder\field\validation\FormFieldValidationError; * @package WoltLabSuite\Core\System\Form\Builder\Field * @since 5.2 */ -abstract class AbstractNumericFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField { +abstract class AbstractNumericFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IInputModeFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField { use TAutoCompleteFormField; use TAutoFocusFormField; use TCssClassFormField; use TImmutableFormField; + use TInputModeFormField; use TMaximumFormField; use TMinimumFormField; use TNullableFormField; @@ -98,6 +99,17 @@ abstract class AbstractNumericFormField extends AbstractFormField implements IAu return $this->step; } + /** + * @inheritDoc + */ + protected function getValidInputModes(): array { + if ($this->integerValues) { + return ['numeric']; + } + + return ['decimal']; + } + /** * @inheritDoc */ -- 2.20.1