pushuo 2022-08-15 19:20:29 +08:00
parent 06b6967285
commit ef64b06977
3 changed files with 15 additions and 13 deletions

View File

@ -1,4 +1,7 @@
<x-admin::form.row :title="$title" :required="$required"> <x-admin::form.row :title="$title" :required="$required">
<input type="text" name="{{ $name }}" class="form-control wp-{{ $width }} {{ $class }}" value="{{ $value }}" placeholder="{{ $title }}"> <input type="text" name="{{ $name }}" class="form-control wp-{{ $width }} {{ $errors->has($name) ? 'is-invalid' : '' }}" value="{{ $value }}" placeholder="{{ $title }}">
@if ($errors->has($name))
<span class="invalid-feedback" role="alert">{{ $errors->first($name) }}</span>
@endif
{{ $slot }} {{ $slot }}
</x-admin::form.row> </x-admin::form.row>

View File

@ -4,9 +4,7 @@
@section('content') @section('content')
<div id="category-app" class="card"> <div id="category-app" class="card">
<div class="card-header"> <div class="card-header">编辑分类</div>
编辑分类
</div>
<div class="card-body"> <div class="card-body">
<form action="{{ admin_route($category->id ? 'categories.update' : 'categories.store', $category) }}" <form action="{{ admin_route($category->id ? 'categories.update' : 'categories.store', $category) }}"
method="POST"> method="POST">
@ -14,18 +12,20 @@
@method($category->id ? 'PUT' : 'POST') @method($category->id ? 'PUT' : 'POST')
<input type="hidden" name="_redirect" value="{{ $_redirect }}"> <input type="hidden" name="_redirect" value="{{ $_redirect }}">
@foreach (locales() as $index => $locale) @if (session('success'))
{{-- <input type="hidden" name="descriptions[{{ $index }}][locale]" value="{{ $locale['code'] }}"> --}} <x-admin-alert type="success" msg="{{ session('success') }}" class="mt-4"/>
@endforeach @endif
<x-admin-form-input-locale name="descriptions.*.name" title="名称" :value="$descriptions" required /> <x-admin-form-input-locale name="descriptions.*.name" title="名称" :value="$descriptions" required />
<x-admin-form-input-locale name="descriptions.*.content" title="内容" :value="$descriptions" /> <x-admin-form-input-locale name="descriptions.*.content" title="内容" :value="$descriptions" />
{{-- <x-admin-form-select title="上级分类" name="parent_id" :value="old('parent_id', $category->parent_id ?? 0)" :options="$categories->toArray()" key="id" label="name" /> --}}
<x-admin::form.row title="上级分类"> <x-admin::form.row title="上级分类">
@php @php
$_parent_id = old('parent_id', $category->parent_id ?? 0); $_parent_id = old('parent_id', $category->parent_id ?? 0);
@endphp @endphp
<select name="parent_id" id="" class="form-control short"> <select name="parent_id" id="" class="form-control short wp-400">
<option value="0">--请选择--</option> <option value="0">--请选择--</option>
@foreach ($categories as $_category) @foreach ($categories as $_category)
<option value="{{ $_category->id }}" {{ $_parent_id == $_category->id ? 'selected' : '' }}> <option value="{{ $_category->id }}" {{ $_parent_id == $_category->id ? 'selected' : '' }}>
@ -38,8 +38,7 @@
<x-admin-form-switch title="状态" name="active" :value="old('active', $category->active ?? 1)" /> <x-admin-form-switch title="状态" name="active" :value="old('active', $category->active ?? 1)" />
<x-admin::form.row> <x-admin::form.row>
<button type="submit" class="btn btn-primary">保存</button> <button type="submit" class="btn btn-primary mt-3">保存</button>
<a href="{{ $_redirect }}" class="btn btn-outline-secondary">返回</a>
</x-admin::form.row> </x-admin::form.row>
</form> </form>

View File

@ -19,15 +19,15 @@
<x-admin-form-input <x-admin-form-input
:name="$column['name']" :name="$column['name']"
:title="$column['label']" :title="$column['label']"
:class="$errors->has($column['name']) ? 'is-invalid' : ''" {{-- :class="$errors->has($column['name']) ? 'is-invalid' : ''" --}}
:required="$column['required'] ? true : false" :required="$column['required'] ? true : false"
:value="old($column['name'], $column['value'] ?? '')"> :value="old($column['name'], $column['value'] ?? '')">
@if (isset($column['description'])) @if (isset($column['description']))
<div class="help-text font-size-12 lh-base">{{ $column['description'] }}</div> <div class="help-text font-size-12 lh-base">{{ $column['description'] }}</div>
@endif @endif
@if ($errors->has($column['name'])) {{-- @if ($errors->has($column['name']))
<span class="invalid-feedback" role="alert">{{ $errors->first($column['name']) }}</span> <span class="invalid-feedback" role="alert">{{ $errors->first($column['name']) }}</span>
@endif @endif --}}
</x-admin-form-input> </x-admin-form-input>
@endif @endif