fix(helpdesk): clean up handover form field handling

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
aminovfariz
2026-06-23 09:27:13 +02:00
parent 0392043ee3
commit 4636374af4
3 changed files with 5 additions and 8 deletions

View File

@@ -72,19 +72,18 @@ $hasDiff = $fieldDiff !== [];
</label> </label>
<select <select
id="<?php e($inputId); ?>" id="<?php e($inputId); ?>"
name="field_<?php e($key); ?>[]" name="field_<?php e($key); ?>"
multiple
size="5"
<?php if ($required): ?> aria-required="true"<?php endif; ?> <?php if ($required): ?> aria-required="true"<?php endif; ?>
<?php if ($readonly): ?> disabled<?php endif; ?> <?php if ($readonly): ?> disabled<?php endif; ?>
> >
<option value=""><?php e(t('Please select...')); ?></option>
<?php foreach ($tenantUsers as $u): <?php foreach ($tenantUsers as $u):
$uId = (string) ($u['u']['id'] ?? $u['id'] ?? ''); $uId = (string) ($u['u']['id'] ?? $u['id'] ?? '');
$uName = trim((string) ($u['u']['display_name'] ?? $u['display_name'] ?? '')); $uName = trim((string) ($u['u']['display_name'] ?? $u['display_name'] ?? ''));
$uEmail = (string) ($u['u']['email'] ?? $u['email'] ?? ''); $uEmail = (string) ($u['u']['email'] ?? $u['email'] ?? '');
$uLabel = $uName !== '' ? $uName : $uEmail; $uLabel = $uName !== '' ? $uName : $uEmail;
?> ?>
<option value="<?php e($uId); ?>"<?php if (in_array($uId, $selectedIds, true)): ?> selected<?php endif; ?>> <option value="<?php e($uId); ?>"<?php if ($value === $uId): ?> selected<?php endif; ?>>
<?php e($uLabel); ?> <?php e($uLabel); ?>
</option> </option>
<?php endforeach; ?> <?php endforeach; ?>

View File

@@ -258,8 +258,7 @@ if ($step === $protocolStep) {
if ($type === 'checkbox') { if ($type === 'checkbox') {
$fieldValues[$key] = $request->body('field_' . $key, '') !== '' ? '1' : '0'; $fieldValues[$key] = $request->body('field_' . $key, '') !== '' ? '1' : '0';
} elseif ($type === 'user-select') { } elseif ($type === 'user-select') {
$ids = $request->body('field_' . $key, []); $fieldValues[$key] = (string) $request->body('field_' . $key, '');
$fieldValues[$key] = json_encode(array_values(array_filter((array) $ids)));
} else { } else {
$fieldValues[$key] = (string) $request->body('field_' . $key, ''); $fieldValues[$key] = (string) $request->body('field_' . $key, '');
} }

View File

@@ -149,8 +149,7 @@ if ($request->isMethod('POST') && $canEdit) {
if ($type === 'checkbox') { if ($type === 'checkbox') {
$submittedValues[$key] = $request->body('field_' . $key, '') !== '' ? '1' : '0'; $submittedValues[$key] = $request->body('field_' . $key, '') !== '' ? '1' : '0';
} elseif ($type === 'user-select') { } elseif ($type === 'user-select') {
$ids = $request->body('field_' . $key, []); $submittedValues[$key] = (string) $request->body('field_' . $key, '');
$submittedValues[$key] = json_encode(array_values(array_filter((array) $ids)));
} else { } else {
$submittedValues[$key] = (string) $request->body('field_' . $key, ''); $submittedValues[$key] = (string) $request->body('field_' . $key, '');
} }