@extends('admin::Layouts.master')
@section('pagecss')
<link rel="stylesheet" type="text/css" href="{{ asset('css/bootstrap-select.min.css') }}">
@stop
@section('content')
<div class="container-fluid py-4">
    @include('partials.messages')
    @include('partials.admin.settings-tabs', ['subactive' => 'prefix'])
    <form action="{{ route('admin.settings-prefix.' . (isset($prefix) ? 'update' : 'store')) }}" method="post">
        @csrf
        <input type="hidden" name="uuid" value="{{ $prefix->uuid ?? '' }}">
        <div class="row">
            <div class="col-12 col-lg-6">
                <label for="prefix" class="required">Präfix:</label>
                <input class="form-control @error('prefix')is-invalid @enderror" name="prefix" id="prefix" value="{{ old('prefix', $prefix->prefix ?? '') }}">
            </div>
            <div class="col-12 col-lg-6">
                <label for="display_style" class="required">Anzeigestil:</label>
                <input class="form-control @error('display_style')is-invalid @enderror" name="display_style" id="display_style" value="{{ old('prefix', $prefix->display_style ?? '') }}">
            </div>
            <div class="col-12 mt-3">
                <label for="forums" class="required">Verfügbar in Foren:</label>
                <select name="forums[]" id="forums" class="selectpicker form-control @error('groups')is-invalid @enderror" data-live-search="true" title="Auswählen..." multiple>
                    @foreach($forums as $forum)
                        <option data-tokens="{{ Str::slug($forum->title) }}"
                                value="{{ $forum->uuid }}"
                                {{ isset($prefix) && $prefix->forums->contains('uuid', $forum->uuid) ? ' selected' : (in_array($forum->uuid, old('forums', [])) ? ' selected' : '') }}>
                            {{ $forum->title }}
                        </option>
                    @endforeach
                </select>
            </div>
            <div class="col-2 mt-3">
                @include('partials.button', ['context' => 'primary', 'type' => 'submit', 'icon' => 'save', 'label' => 'Speichern'])
            </div>
        </div>
    </form>
</div>
@stop
@section('pagejs')
<script src="{{ asset('js/bootstrap-select.min.js') }}"></script>
@stop
