fix(select): Leerzeichen in Pipe-getrennten Select-Optionen trimmen
field_options wie "Ferris|Digital 1 Richtung| Digital 2 Richtung" führten
zu Leerzeichen nach split('|'), wodurch der Vergleich mit dem gespeicherten
Wert fehlschlug und das Select-Feld beim Editieren leer blieb.
Fix: opt.trim() in JS bei allen Select-Renderings (DynamicFields,
SchematicEditor, PWA) + automatisches Trimmen beim Speichern in Admin.
DB-Werte in Produktion bereinigt.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
65f24495e6
commit
7de0349808
4 changed files with 25 additions and 3 deletions
|
|
@ -208,6 +208,10 @@ if ($action == 'add_field') {
|
|||
$fieldLabel = GETPOST('field_label', 'alphanohtml');
|
||||
$fieldType = GETPOST('field_type', 'aZ09');
|
||||
$fieldOptions = GETPOST('field_options', 'nohtml');
|
||||
// Leerzeichen um Pipe-Trennzeichen entfernen und leere Optionen entfernen
|
||||
if ($fieldOptions) {
|
||||
$fieldOptions = implode('|', array_filter(array_map('trim', explode('|', $fieldOptions)), 'strlen'));
|
||||
}
|
||||
$showInTree = GETPOSTINT('show_in_tree');
|
||||
$treeDisplayMode = GETPOST('tree_display_mode', 'aZ09');
|
||||
if (empty($treeDisplayMode)) $treeDisplayMode = 'badge';
|
||||
|
|
@ -243,6 +247,10 @@ if ($action == 'update_field') {
|
|||
$fieldLabel = GETPOST('field_label', 'alphanohtml');
|
||||
$fieldType = GETPOST('field_type', 'aZ09');
|
||||
$fieldOptions = GETPOST('field_options', 'nohtml');
|
||||
// Leerzeichen um Pipe-Trennzeichen entfernen und leere Optionen entfernen
|
||||
if ($fieldOptions) {
|
||||
$fieldOptions = implode('|', array_filter(array_map('trim', explode('|', $fieldOptions)), 'strlen'));
|
||||
}
|
||||
$showInTree = GETPOSTINT('show_in_tree');
|
||||
$treeDisplayMode = GETPOST('tree_display_mode', 'aZ09');
|
||||
if (empty($treeDisplayMode)) $treeDisplayMode = 'badge';
|
||||
|
|
|
|||
8
admin/equipment_types.php
Executable file → Normal file
8
admin/equipment_types.php
Executable file → Normal file
|
|
@ -228,6 +228,10 @@ if ($action == 'add_field') {
|
|||
$fieldLabel = GETPOST('field_label', 'alphanohtml');
|
||||
$fieldType = GETPOST('field_type', 'aZ09');
|
||||
$fieldOptions = GETPOST('field_options', 'nohtml');
|
||||
// Leerzeichen um Pipe-Trennzeichen entfernen und leere Optionen entfernen
|
||||
if ($fieldOptions) {
|
||||
$fieldOptions = implode('|', array_filter(array_map('trim', explode('|', $fieldOptions)), 'strlen'));
|
||||
}
|
||||
$showInHover = GETPOSTINT('show_in_hover');
|
||||
$showOnBlock = GETPOSTINT('show_on_block');
|
||||
$isRequired = GETPOSTINT('is_required');
|
||||
|
|
@ -256,6 +260,10 @@ if ($action == 'update_field') {
|
|||
$fieldLabel = GETPOST('field_label', 'alphanohtml');
|
||||
$fieldType = GETPOST('field_type', 'aZ09');
|
||||
$fieldOptions = GETPOST('field_options', 'nohtml');
|
||||
// Leerzeichen um Pipe-Trennzeichen entfernen und leere Optionen entfernen
|
||||
if ($fieldOptions) {
|
||||
$fieldOptions = implode('|', array_filter(array_map('trim', explode('|', $fieldOptions)), 'strlen'));
|
||||
}
|
||||
$showInHover = GETPOSTINT('show_in_hover');
|
||||
$showOnBlock = GETPOSTINT('show_on_block');
|
||||
$isRequired = GETPOSTINT('is_required');
|
||||
|
|
|
|||
|
|
@ -1557,7 +1557,9 @@
|
|||
if (field.options) {
|
||||
var options = field.options.split('|');
|
||||
options.forEach(function(opt) {
|
||||
var selected = (opt === value) ? ' selected' : '';
|
||||
opt = opt.trim();
|
||||
if (opt === '') return;
|
||||
var selected = (opt === value.trim()) ? ' selected' : '';
|
||||
html += '<option value="' + KundenKarte.DynamicFields.escapeHtml(opt) + '"' + selected + '>' + KundenKarte.DynamicFields.escapeHtml(opt) + '</option>';
|
||||
});
|
||||
}
|
||||
|
|
@ -8338,7 +8340,9 @@
|
|||
html += '<option value="">-- Wählen --</option>';
|
||||
var options = field.field_options.split('|');
|
||||
options.forEach(function(opt) {
|
||||
var selected = (opt === value) ? ' selected' : '';
|
||||
opt = opt.trim();
|
||||
if (opt === '') return;
|
||||
var selected = (opt === value.trim()) ? ' selected' : '';
|
||||
html += '<option value="' + self.escapeHtml(opt) + '"' + selected + '>' + self.escapeHtml(opt) + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
|
|
|
|||
|
|
@ -1614,7 +1614,9 @@
|
|||
html += `<option value="">--</option>`;
|
||||
if (field.options) {
|
||||
field.options.split('|').forEach(opt => {
|
||||
const selected = (opt === val) ? ' selected' : '';
|
||||
opt = opt.trim();
|
||||
if (!opt) return;
|
||||
const selected = (opt === val.trim()) ? ' selected' : '';
|
||||
html += `<option value="${escapeHtml(opt)}"${selected}>${escapeHtml(opt)}</option>`;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue