|
|
@@ -76,7 +76,11 @@ if ($edit_id) {
|
|
|
|
|
|
<?php foreach ($form_data['questions'] as $q): ?>
|
|
|
<div class="form-group">
|
|
|
- <label><?= htmlspecialchars($q['label']) ?> *</label>
|
|
|
+ <?php
|
|
|
+ $is_required = !isset($q['required']) || $q['required'] === true;
|
|
|
+ $req_attr = $is_required ? 'required' : '';
|
|
|
+ ?>
|
|
|
+ <label><?= htmlspecialchars($q['label']) ?><?= $is_required ? ' *' : '' ?></label>
|
|
|
<?php
|
|
|
$val = $existing_answers[$q['id']] ?? '';
|
|
|
$is_array_val = is_array($val);
|
|
|
@@ -101,7 +105,7 @@ if ($edit_id) {
|
|
|
}
|
|
|
|
|
|
if ($q['type'] === 'textarea'): ?>
|
|
|
- <textarea id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" rows="4" required><?= htmlspecialchars(is_string($val) ? $val : '') ?></textarea>
|
|
|
+ <textarea id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" rows="4" <?= $req_attr ?>><?= htmlspecialchars(is_string($val) ? $val : '') ?></textarea>
|
|
|
|
|
|
<?php elseif ($q['type'] === 'single_choice'): ?>
|
|
|
<div class="options-container" style="display:flex; flex-direction:column; gap:0.5rem; margin-top:0.5rem;">
|
|
|
@@ -109,13 +113,13 @@ if ($edit_id) {
|
|
|
$checked = (is_string($val) && $val === $opt) ? 'checked' : '';
|
|
|
?>
|
|
|
<label style="font-weight:normal; display:flex; align-items:center; gap:0.5rem;">
|
|
|
- <input type="radio" name="answers[<?= htmlspecialchars($q['id']) ?>]" value="<?= htmlspecialchars($opt) ?>" required <?= $checked ?> style="width:auto; margin:0;">
|
|
|
+ <input type="radio" name="answers[<?= htmlspecialchars($q['id']) ?>]" value="<?= htmlspecialchars($opt) ?>" <?= $req_attr ?> <?= $checked ?> style="width:auto; margin:0;">
|
|
|
<?= htmlspecialchars($opt) ?>
|
|
|
</label>
|
|
|
<?php endforeach; ?>
|
|
|
<?php if (!empty($q['allow_free_text'])): ?>
|
|
|
<label style="font-weight:normal; display:flex; align-items:center; gap:0.5rem;">
|
|
|
- <input type="radio" name="answers[<?= htmlspecialchars($q['id']) ?>]" value="__freetext__" required <?= $is_freetext_val ? 'checked' : '' ?> style="width:auto; margin:0;">
|
|
|
+ <input type="radio" name="answers[<?= htmlspecialchars($q['id']) ?>]" value="__freetext__" <?= $req_attr ?> <?= $is_freetext_val ? 'checked' : '' ?> style="width:auto; margin:0;">
|
|
|
Sonstiges:
|
|
|
<input type="text" name="answers_freetext[<?= htmlspecialchars($q['id']) ?>]" value="<?= htmlspecialchars($freetext_content) ?>" style="margin-left: 0.5rem; flex:1;">
|
|
|
</label>
|
|
|
@@ -142,7 +146,7 @@ if ($edit_id) {
|
|
|
</div>
|
|
|
|
|
|
<?php elseif ($q['type'] === 'dropdown'): ?>
|
|
|
- <select id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" required>
|
|
|
+ <select id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" <?= $req_attr ?>>
|
|
|
<option value="">-- Bitte auswählen --</option>
|
|
|
<?php foreach ($q['options'] as $opt):
|
|
|
$selected = (is_string($val) && $val === $opt) ? 'selected' : '';
|
|
|
@@ -152,7 +156,7 @@ if ($edit_id) {
|
|
|
</select>
|
|
|
|
|
|
<?php else: ?>
|
|
|
- <input type="text" id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" required value="<?= htmlspecialchars(is_string($val) ? $val : '') ?>">
|
|
|
+ <input type="text" id="<?= htmlspecialchars($q['id']) ?>" name="answers[<?= htmlspecialchars($q['id']) ?>]" <?= $req_attr ?> value="<?= htmlspecialchars(is_string($val) ? $val : '') ?>">
|
|
|
<?php endif; ?>
|
|
|
</div>
|
|
|
<?php endforeach; ?>
|