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:
Eduard Wisch 2026-03-03 21:34:00 +01:00
parent 65f24495e6
commit 7de0349808
4 changed files with 25 additions and 3 deletions

View file

@ -208,6 +208,10 @@ if ($action == 'add_field') {
$fieldLabel = GETPOST('field_label', 'alphanohtml'); $fieldLabel = GETPOST('field_label', 'alphanohtml');
$fieldType = GETPOST('field_type', 'aZ09'); $fieldType = GETPOST('field_type', 'aZ09');
$fieldOptions = GETPOST('field_options', 'nohtml'); $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'); $showInTree = GETPOSTINT('show_in_tree');
$treeDisplayMode = GETPOST('tree_display_mode', 'aZ09'); $treeDisplayMode = GETPOST('tree_display_mode', 'aZ09');
if (empty($treeDisplayMode)) $treeDisplayMode = 'badge'; if (empty($treeDisplayMode)) $treeDisplayMode = 'badge';
@ -243,6 +247,10 @@ if ($action == 'update_field') {
$fieldLabel = GETPOST('field_label', 'alphanohtml'); $fieldLabel = GETPOST('field_label', 'alphanohtml');
$fieldType = GETPOST('field_type', 'aZ09'); $fieldType = GETPOST('field_type', 'aZ09');
$fieldOptions = GETPOST('field_options', 'nohtml'); $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'); $showInTree = GETPOSTINT('show_in_tree');
$treeDisplayMode = GETPOST('tree_display_mode', 'aZ09'); $treeDisplayMode = GETPOST('tree_display_mode', 'aZ09');
if (empty($treeDisplayMode)) $treeDisplayMode = 'badge'; if (empty($treeDisplayMode)) $treeDisplayMode = 'badge';

8
admin/equipment_types.php Executable file → Normal file
View file

@ -228,6 +228,10 @@ if ($action == 'add_field') {
$fieldLabel = GETPOST('field_label', 'alphanohtml'); $fieldLabel = GETPOST('field_label', 'alphanohtml');
$fieldType = GETPOST('field_type', 'aZ09'); $fieldType = GETPOST('field_type', 'aZ09');
$fieldOptions = GETPOST('field_options', 'nohtml'); $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'); $showInHover = GETPOSTINT('show_in_hover');
$showOnBlock = GETPOSTINT('show_on_block'); $showOnBlock = GETPOSTINT('show_on_block');
$isRequired = GETPOSTINT('is_required'); $isRequired = GETPOSTINT('is_required');
@ -256,6 +260,10 @@ if ($action == 'update_field') {
$fieldLabel = GETPOST('field_label', 'alphanohtml'); $fieldLabel = GETPOST('field_label', 'alphanohtml');
$fieldType = GETPOST('field_type', 'aZ09'); $fieldType = GETPOST('field_type', 'aZ09');
$fieldOptions = GETPOST('field_options', 'nohtml'); $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'); $showInHover = GETPOSTINT('show_in_hover');
$showOnBlock = GETPOSTINT('show_on_block'); $showOnBlock = GETPOSTINT('show_on_block');
$isRequired = GETPOSTINT('is_required'); $isRequired = GETPOSTINT('is_required');

View file

@ -1557,7 +1557,9 @@
if (field.options) { if (field.options) {
var options = field.options.split('|'); var options = field.options.split('|');
options.forEach(function(opt) { 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>'; html += '<option value="' + KundenKarte.DynamicFields.escapeHtml(opt) + '"' + selected + '>' + KundenKarte.DynamicFields.escapeHtml(opt) + '</option>';
}); });
} }
@ -8338,7 +8340,9 @@
html += '<option value="">-- Wählen --</option>'; html += '<option value="">-- Wählen --</option>';
var options = field.field_options.split('|'); var options = field.field_options.split('|');
options.forEach(function(opt) { 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 += '<option value="' + self.escapeHtml(opt) + '"' + selected + '>' + self.escapeHtml(opt) + '</option>';
}); });
html += '</select>'; html += '</select>';

View file

@ -1614,7 +1614,9 @@
html += `<option value="">--</option>`; html += `<option value="">--</option>`;
if (field.options) { if (field.options) {
field.options.split('|').forEach(opt => { 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>`; html += `<option value="${escapeHtml(opt)}"${selected}>${escapeHtml(opt)}</option>`;
}); });
} }