text field: add trimValue config

Inspired by a recent bug detected in the subscription key field, where
a trailing white space caused verification issues.

We might even enable the trimming by default, after checking call
sites that is – most often one wants to trim the text to be submitted

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-10-24 13:58:04 +02:00
parent 5a3ac9b110
commit 5d7d30de0f

View File

@ -6,6 +6,8 @@ Ext.define('Proxmox.form.field.Textfield', {
skipEmptyText: true,
deleteEmpty: false,
trimValue: false,
},
getSubmitData: function() {
@ -29,6 +31,9 @@ Ext.define('Proxmox.form.field.Textfield', {
let me = this;
let value = this.processRawValue(this.getRawValue());
if (me.getTrimValue() && typeof value === 'string') {
value = value.trim();
}
if (value !== '') {
return value;
}