38 lines
2.3 KiB
PHP
38 lines
2.3 KiB
PHP
<?php
|
||
$v = function ($k, $d = '') use ($c) { return $c ? ($c[$k] ?? $d) : $d; };
|
||
$isEdit = !empty($c);
|
||
?>
|
||
<div class="page-head">
|
||
<div><h1><?php echo $isEdit ? '编辑分类' : '新增分类'; ?></h1></div>
|
||
<a class="btn-ghost" href="<?php echo site_url('admin/categories'); ?>">← 返回</a>
|
||
</div>
|
||
<div class="admin-card">
|
||
<form id="pbForm" method="post" action="<?php echo site_url($isEdit ? 'admin/categories/update/' . $c['id'] : 'admin/categories/store'); ?>">
|
||
<?php echo csrf_field(); ?>
|
||
<div class="form-grid">
|
||
<div class="field"><label>分类名称 *</label><input name="name" value="<?php echo e($v('name')); ?>" required></div>
|
||
<div class="field"><label>图标(emoji)</label><input name="icon" value="<?php echo e($v('icon', '❄')); ?>"></div>
|
||
<div class="field"><label>标识(留空按序号生成)</label><input name="slug" value="<?php echo e($v('slug')); ?>"></div>
|
||
<div class="field"><label>排序</label><input name="sort_order" type="number" value="<?php echo e($v('sort_order', 0)); ?>"></div>
|
||
</div>
|
||
<div class="field">
|
||
<label>描述(可视化编辑)</label>
|
||
<p class="pb-hint" style="margin:0 0 8px">下方为可视化编辑器:上传素材、拖拽文字/图片/按钮自由排版。当前分类无独立前台详情页,编辑保存后可用于后续扩展或作为内容版式储备。</p>
|
||
<?php
|
||
$layoutJson = $v('layout');
|
||
$layoutArr = $layoutJson ? @json_decode($layoutJson, true) : [];
|
||
if (!is_array($layoutArr)) $layoutArr = [];
|
||
echo \Core\View::buffer('admin/parts/builder', ['module' => 'category', 'layout' => $layoutArr]);
|
||
?>
|
||
<input type="hidden" name="layout" id="pbLayout">
|
||
</div>
|
||
<div class="field" style="display:flex;align-items:center;gap:8px">
|
||
<input type="checkbox" name="status" value="1" <?php echo $v('status', 1) ? 'checked' : ''; ?> id="st"> <label for="st" style="margin:0">显示</label>
|
||
</div>
|
||
<div class="form-actions">
|
||
<button class="btn-primary" type="submit">保存</button>
|
||
<a class="btn-ghost" href="<?php echo site_url('admin/categories'); ?>">取消</a>
|
||
</div>
|
||
</form>
|
||
</div>
|