<link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.8/dist/trix.css">
<script type="text/javascript" src="https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js"></script>
<h4 class="fw-bold">Добавить новость</h4>
<form action="{{ route('admin.posts.update', ['post' => $post]) }}" method="post" enctype="multipart/form-data">
    @csrf
    <div class="mb-3">
        <label for="titleFormControlTextarea" class="form-label">Заголовок</label>
        <textarea class="form-control" id="titleFormControlTextarea1" name="name" rows="2">{{ $post->name }}</textarea>
        @error('name')
            <div class="text-danger">{{ $message }}</div>
        @enderror
    </div>
    <div class="row">
        <div class="col mb-3">
            <label for="categoryFormControlSelect" class="form-label">Категория</label>
            <select class="form-select" id="categoryFormControlSelect" name="category" aria-label="">
                @foreach ($categories as $category)
                    <option value="{{ $category->value }}" {{ $post->category == $category->value ? 'selected' : '' }}>
                        {{ __($category->name) }}
                    </option>
                @endforeach
            </select>
            @error('category')
                <div class="text-danger">{{ $message }}</div>
            @enderror
        </div>
        <div class="col mb-3">
            <label for="formFile" class="form-label">Заставка новости</label>
            <input class="form-control" type="file" id="formFile" name="imageFile">
            @error('imageFile')
                <div class="text-danger">{{ $message }}</div>
            @enderror
        </div>
    </div>
    <div class="mb-3">
        <label for="shortTextFormControlTextarea" class="form-label">Анонс</label>
        <textarea class="form-control" id="shortTextFormControlTextarea1" name="short_text"
            rows="3">{{ $post->short_text }}</textarea>
        @error('short_text')
            <div class="text-danger">{{ $message }}</div>
        @enderror
    </div>
    <div class="mb-3">
        <label for="shortTextFormControlTextarea" class="form-label">Основной текст</label>
        <textarea class="form-control d-none" id="textFormControlTextarea" name="text"
            rows="15">{{ $post->text }}</textarea>
        <trix-editor input="textFormControlTextarea" class="overflow-auto" style="height:300px"></trix-editor>
        @error('text')
            <div class="text-danger">{{ $message }}</div>
        @enderror
    </div>
    <button type="submit" class="btn btn-primary">Сохранить</button>
</form>