femanager
femanager copied to clipboard
Case sensitive problem with upper letters by registration a new username
There is a Problem with register a new username with upper Letters. The registration templates allow an upper letter input.
If you register upper letters in later edit in the typo3-backend, the username will transform upper letters to lower during saving and editing the inputfield.
Reason:
the column username is marked in typo3 core for lowercase ('eval' => 'nospace,trim,lower,uniqueInPid,required').
in /typo3/sysext/frontend/Configuration/TCA/fe_users.php
'username' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:fe_users.username',
'config' => [
'type' => 'input',
'size' => 20,
'max' => 255,
'eval' => 'nospace,trim,lower,uniqueInPid,required',
'autocomplete' => false,
],
],
My Solution:
I register a JavaScript with the class “transform-value-to-lower-case”, which transform uppercase letters to lowercase letters:
<femanager:form.textfield
id="femanager_field_username"
property="username"
class="form-control transform-value-to-lower-case"
additionalAttributes="{femanager:Validation.FormValidationData(settings:settings,fieldName:'username')}" />
main.js
jQuery(document).ready(function () {
Main.init();
});
let Main = {
init : function() {
jQuery(".transform-value-to-lower-case").on('change keyup paste',this.inputTransformToLowerCase);
},
inputTransformToLowerCase: function(e){
//preserving the position of the cursor
var start = e.target.selectionStart;
//Converting text to lowercase
$(this).val($(this).val().toLowerCase());
//Jumping back to the old position of the cursor
e.target.selectionStart = e.target.selectionEnd = start;
}
}
A better solution will be, if the Extension additionally check the "lower" in the "eval"-Key in the TCA-Config!
Please add my or other solution in the extension!
Thanks