Add autocomplete support for numeric form fields
authorMatthias Schmidt <gravatronics@live.com>
Sat, 19 Dec 2020 12:17:18 +0000 (13:17 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 21 Dec 2020 17:55:55 +0000 (18:55 +0100)
com.woltlab.wcf/templates/__numericFormField.tpl
wcfsetup/install/files/acp/templates/__numericFormField.tpl
wcfsetup/install/files/lib/system/form/builder/field/AbstractNumericFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/FloatFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/IntegerFormField.class.php

index 6877a52355518233c155bdd3a48b1922847a5f99..40baa2a2d12929c6b2b92b82da6f7b89de862b48 100644 (file)
@@ -8,6 +8,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}value="{$field->getValue()}"{*
        *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{*
+       *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index 6877a52355518233c155bdd3a48b1922847a5f99..40baa2a2d12929c6b2b92b82da6f7b89de862b48 100644 (file)
@@ -8,6 +8,7 @@
        *}name="{@$field->getPrefixedId()}" {*
        *}value="{$field->getValue()}"{*
        *}{if !$field->getFieldClasses()|empty} class="{implode from=$field->getFieldClasses() item='class' glue=' '}{$class}{/implode}"{/if}{*
+       *}{if $field->getAutoComplete() !== null} autocomplete="{$field->getAutoComplete()}"{/if}{*
        *}{if $field->isAutofocused()} autofocus{/if}{*
        *}{if $field->isRequired()} required{/if}{*
        *}{if $field->isImmutable()} disabled{/if}{*
index 112e18887c1ddb6d5279c733eaa5ecf1431b435d..e366f0ae6408220d84d56b11fd9cb4d14b57a81b 100644 (file)
@@ -11,7 +11,8 @@ use wcf\system\form\builder\field\validation\FormFieldValidationError;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-abstract class AbstractNumericFormField extends AbstractFormField implements IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+abstract class AbstractNumericFormField extends AbstractFormField implements IAutoCompleteFormField, IAutoFocusFormField, ICssClassFormField, IImmutableFormField, IMaximumFormField, IMinimumFormField, INullableFormField, IPlaceholderFormField, ISuffixedFormField {
+       use TAutoCompleteFormField;
        use TAutoFocusFormField;
        use TCssClassFormField;
        use TImmutableFormField;
index 5ec9297551e6d37e9d4105d23c45fe4ff570b4bc..6a178cd8e7c179d94698569b006574868c3328f3 100644 (file)
@@ -12,4 +12,14 @@ namespace wcf\system\form\builder\field;
  * @package    WoltLabSuite\Core\System\Form\Builder\Field
  * @since      5.2
  */
-class FloatFormField extends AbstractNumericFormField {}
+class FloatFormField extends AbstractNumericFormField {
+       /**
+        * @inheritDoc
+        * @since       5.4
+        */
+       protected function getValidAutoCompleteTokens(): array {
+               return [
+                       'transaction-amount',
+               ];
+       }
+}
index acc8cade20af78279ad01b90d82ebabd59e55bf0..a51fbcdc3d5ee2af217033395ee2e096397496eb 100644 (file)
@@ -17,4 +17,18 @@ class IntegerFormField extends AbstractNumericFormField {
         * @inheritDoc
         */
        protected $integerValues = true;
+       
+       /**
+        * @inheritDoc
+        * @since       5.4
+        */
+       protected function getValidAutoCompleteTokens(): array {
+               return [
+                       'cc-exp-month',
+                       'cc-exp-year',
+                       'bday-day',
+                       'bday-month',
+                       'bday-year',
+               ];
+       }
 }