Forms
Category Form Fields code
Copy the implementation or inspect every file that belongs to this component unit.
resources/views/components/ui/category-form-fields.blade.php
@props([
'category' => null,
])
@php
$errorBag = isset($errors) ? $errors : new \Illuminate\Support\ViewErrorBag;
/*
| Shared category form fields for create and edit screens.
|
| Usage:
| <form ...>
| @csrf
| <x-ui.category-form-fields />
| <x-ui.form-actions>...</x-ui.form-actions>
| </form>
*/
@endphp
<x-ui.field label="Name" for="name" :error="$errorBag->first('name')" required>
<x-ui.input
id="name"
name="name"
:value="old('name', $category?->name)"
:placeholder="$category ? null : 'e.g. Engineering'"
:invalid="$errorBag->has('name')"
/>
</x-ui.field>
<x-ui.field label="Sort order" for="sort_order" :error="$errorBag->first('sort_order')" hint="Lower numbers appear first." optional>
<x-ui.int-input
id="sort_order"
name="sort_order"
:value="old('sort_order', $category?->sort_order ?? 0)"
min="0"
max="9999"
:invalid="$errorBag->has('sort_order')"
/>
</x-ui.field>
<x-ui.field label="Description" for="description" :error="$errorBag->first('description')" hint="A short summary shown on the category page." optional>
<x-ui.textarea
id="description"
name="description"
rows="4"
:placeholder="$category ? null : 'What kind of posts belong here?'"
:invalid="$errorBag->has('description')"
>{{ old('description', $category?->description) }}</x-ui.textarea>
</x-ui.field>