[TASK] Show remaining characters in BE user settings module 58/51458/3
authorGeorg Ringer <georg.ringer@gmail.com>
Sun, 29 Jan 2017 19:25:56 +0000 (20:25 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 2 Feb 2017 14:55:53 +0000 (15:55 +0100)
The fields name & email are saved in the database and therefore
the length of its value should be checked client side to give users
a hint about the maximal length.

Use the requireJS module of FormEngine for providing the
information about the remaining available characters.

Resolves: #79532
Releases: master, 7.6
Change-Id: Ic727fcae493060fed45ddf5b3d05c5070b236a0f
Reviewed-on: https://review.typo3.org/51458
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/setup/Classes/Controller/SetupModuleController.php
typo3/sysext/setup/ext_tables.php

index 6ded02c..79a0fd0 100644 (file)
@@ -166,7 +166,13 @@ class SetupModuleController extends AbstractModule
     {
         parent::__construct();
         $this->formProtection = FormProtectionFactory::get();
-        $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
+        $pageRenderer = $this->moduleTemplate->getPageRenderer();
+        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
+        $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/FormEngine');
+        $pageRenderer->addInlineSetting('FormEngine', 'formName', 'editform');
+        $pageRenderer->addInlineLanguageLabelArray([
+            'FormEngine.remainingCharacters'    => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.remainingCharacters',
+        ], true);
     }
 
     /**
@@ -521,6 +527,12 @@ class SetupModuleController extends AbstractModule
                 case 'email':
                 case 'password':
                     $noAutocomplete = '';
+
+                    $maxLength = $config['max'] ?? 0;
+                    if ((int)$maxLength > 0) {
+                        $more .= ' maxlength="' . (int)$maxLength . '"';
+                    }
+
                     if ($type === 'password') {
                         $value = '';
                         $noAutocomplete = 'autocomplete="off" ';
@@ -624,7 +636,7 @@ class SetupModuleController extends AbstractModule
                     $html = '';
             }
 
-            $code[] = '<div class="form-section"><div class="row"><div class="form-group col-md-12">' .
+            $code[] = '<div class="form-section"><div class="row"><div class="form-group t3js-formengine-field-item col-md-12">' .
                 $label .
                 $html .
                 '</div></div></div>';
index f0e7f90..dc18599 100644 (file)
@@ -26,13 +26,15 @@ if (TYPO3_MODE === 'BE') {
                 'type' => 'text',
                 'label' => 'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:beUser_realName',
                 'table' => 'be_users',
-                'csh' => 'beUser_realName'
+                'csh' => 'beUser_realName',
+                'max' => 80
             ],
             'email' => [
                 'type' => 'email',
                 'label' => 'LLL:EXT:setup/Resources/Private/Language/locallang.xlf:beUser_email',
                 'table' => 'be_users',
-                'csh' => 'beUser_email'
+                'csh' => 'beUser_email',
+                'max' => 80
             ],
             'emailMeAtLogin' => [
                 'type' => 'check',