[BUGFIX] Show remaining chars for InputElement only if defined 12/41312/2
authorGeorg Ringer <georg.ringer@gmail.com>
Wed, 15 Jul 2015 15:22:47 +0000 (17:22 +0200)
committerFrank Nägler <frank.naegler@typo3.org>
Wed, 15 Jul 2015 15:51:50 +0000 (17:51 +0200)
If no max is defined in the TCA the remaining characters can not be
determined without checking the DB. It is not a good idea to show a
hardcoded size of 256.

Change the code to be in sync with the TextElement and check the max
configuration first.

Change-Id: Ia74ea88e22b6344e8ce1a44e3795dc11d4466dba
Resolves: #68176
Releases: master
Reviewed-on: http://review.typo3.org/41312
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/backend/Classes/Form/Element/InputElement.php

index d589b9e..c5c7e17 100644 (file)
@@ -171,8 +171,9 @@ class InputElement extends AbstractFormElement {
                $attributes['id'] = str_replace('.', '', uniqid('formengine-input-', TRUE));
                $attributes['name'] = $parameterArray['itemFormElName'] . '_hr';
                $attributes['value'] = '';
                $attributes['id'] = str_replace('.', '', uniqid('formengine-input-', TRUE));
                $attributes['name'] = $parameterArray['itemFormElName'] . '_hr';
                $attributes['value'] = '';
-               $attributes['maxlength'] = $config['max'] ?: 256;
-
+               if (isset($config['max']) && (int)$config['max'] > 0) {
+                       $attributes['maxlength'] = (int)$config['max'];
+               }
                if (!empty($styles)) {
                        $attributes['style'] = implode(' ', $styles);
                }
                if (!empty($styles)) {
                        $attributes['style'] = implode(' ', $styles);
                }