[FEATURE] Use HTML5 field types and attributes in FormEngine 28/57328/5
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 22 Jun 2018 23:00:31 +0000 (01:00 +0200)
committerMathias Brodala <mbrodala@pagemachine.de>
Sat, 23 Jun 2018 09:23:02 +0000 (11:23 +0200)
The FormEngine renders now HTML5 specific field types and attributes
based on its `eval` config.

Resolves: #85355
Releases: master
Change-Id: I66fa54e5b475e519b75b04f33a3c1c55cef2646e
Reviewed-on: https://review.typo3.org/57328
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Patrick Schriner <patrick.schriner@diemedialen.de>
Tested-by: Patrick Schriner <patrick.schriner@diemedialen.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
typo3/sysext/backend/Classes/Form/Element/InputTextElement.php
typo3/sysext/core/Documentation/Changelog/master/Feature-85355-SupportBasicHTML5FieldsInFormEngine.rst [new file with mode: 0644]

index a433575..80bcfbf 100644 (file)
@@ -210,12 +210,26 @@ class InputTextElement extends AbstractFormElement
         $fieldWizardResult = $this->renderFieldWizard();
         $fieldWizardHtml = $fieldWizardResult['html'];
         $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false);
+        $inputType = 'text';
+
+        if (in_array('email', $evalList, true)) {
+            $inputType = 'email';
+        } elseif (!empty(array_intersect($evalList, ['int', 'num']))) {
+            $inputType = 'number';
+
+            if (isset($config['range']['lower'])) {
+                $attributes['min'] = (int)$config['range']['lower'];
+            }
+            if (isset($config['range']['upper'])) {
+                $attributes['max'] = (int)$config['range']['upper'];
+            }
+        }
 
         $mainFieldHtml = [];
         $mainFieldHtml[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
         $mainFieldHtml[] =  '<div class="form-wizards-wrap">';
         $mainFieldHtml[] =      '<div class="form-wizards-element">';
-        $mainFieldHtml[] =          '<input type="text"' . GeneralUtility::implodeAttributes($attributes, true) . ' />';
+        $mainFieldHtml[] =          '<input type="' . $inputType . '"' . GeneralUtility::implodeAttributes($attributes, true) . ' />';
         $mainFieldHtml[] =          '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />';
         $mainFieldHtml[] =      '</div>';
         $mainFieldHtml[] =      '<div class="form-wizards-items-aside">';
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-85355-SupportBasicHTML5FieldsInFormEngine.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-85355-SupportBasicHTML5FieldsInFormEngine.rst
new file mode 100644 (file)
index 0000000..87ef2e4
--- /dev/null
@@ -0,0 +1,23 @@
+.. include:: ../../Includes.txt
+
+==========================================================
+Feature: #85355 - Support basic HTML5 fields in FormEngine
+==========================================================
+
+See :issue:`85355`
+
+Description
+===========
+
+The FormEngine renders now HTML5 specific field types and attributes.
+
+
+Impact
+======
+
+Depending on the :php:`eval` configuration, the input types may be :html:`text`, :html:`number`
+or :html:`email.`
+If :php:`range` is configured, its values are stored in :html:`min` and :html:`max` attributes
+for number fields.
+
+.. index:: Backend, ext:backend