Files
CRM-IKZ/app/Views/admin/boards/fields/edit.php
T
2026-07-14 08:19:56 +04:00

73 lines
3.3 KiB
PHP

<?php
$settings = json_decode((string)($field['settings_json'] ?? ''), true);
$optionsText = '';
if (!empty($settings['options']) && is_array($settings['options'])) {
$optionsText = implode("\n", $settings['options']);
}
?>
<h1 class="h3 mb-3">Изменение поля</h1>
<div class="card shadow-sm">
<div class="card-body">
<form method="post" action="/admin/boards/fields/update">
<input type="hidden" name="id" value="<?= (int)$field['id'] ?>">
<div class="mb-3">
<label class="form-label">Доска</label>
<input type="text" class="form-control" value="<?= htmlspecialchars((string)$field['board_name']) ?>" disabled>
</div>
<div class="mb-3">
<label class="form-label">Код</label>
<input type="text" name="code" class="form-control" value="<?= htmlspecialchars((string)$field['code']) ?>" required>
</div>
<div class="mb-3">
<label class="form-label">Название</label>
<input type="text" name="name" class="form-control" value="<?= htmlspecialchars((string)$field['name']) ?>" required>
</div>
<div class="mb-3">
<label class="form-label">Тип поля</label>
<select name="field_type" class="form-select" id="field_type">
<?php foreach (['text','textarea','number','date','select','checkbox'] as $type): ?>
<option value="<?= $type ?>" <?= $field['field_type'] === $type ? 'selected' : '' ?>>
<?= $type ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3" id="select_options_wrap" style="<?= $field['field_type'] === 'select' ? '' : 'display:none;' ?>">
<label class="form-label">Варианты select</label>
<textarea name="select_options" class="form-control" rows="5"><?= htmlspecialchars($optionsText) ?></textarea>
</div>
<div class="mb-3">
<label class="form-label">Порядок</label>
<input type="number" name="sort_order" class="form-control" value="<?= (int)$field['sort_order'] ?>">
</div>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" name="is_required" id="is_required" <?= (int)$field['is_required'] ? 'checked' : '' ?>>
<label class="form-check-label" for="is_required">Обязательное</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" name="is_active" id="is_active" <?= (int)$field['is_active'] ? 'checked' : '' ?>>
<label class="form-check-label" for="is_active">Активное</label>
</div>
<button type="submit" class="btn btn-success">Сохранить</button>
<a href="/admin/boards/fields?id=<?= (int)$field['board_id'] ?>" class="btn btn-secondary">Назад</a>
</form>
</div>
</div>
<script>
document.getElementById('field_type').addEventListener('change', function () {
document.getElementById('select_options_wrap').style.display = this.value === 'select' ? 'block' : 'none';
});
</script>