@php use Seka\Vzdelavanie\Enums\ModelStatusEnum; @endphp
<form class="row" method="post" action="{{ $actionRoute }}">
    @if(isset($edit) && $edit === true)
        @method('PUT')
    @endif
    @csrf()
    <div class="col-12">
        <div class="form-group">
            <label>
                Názov
                <span class="text-red">*</span>
            </label>
            <input class="form-control @if($errors->has('nazov')) is-invalid @endif" type="text" name="nazov"
                   placeholder="názov testu" value="{{ $test->nazov ?? old('nazov') }}" required autofocus>
            @if($errors->has('nazov'))
                @foreach($errors->get('nazov') as $message)
                    <div class="invalid-feedback">{{ $message }}</div>
                @endforeach
            @endif
        </div>
    </div>
    <div class="col-12">
        <div class="form-group">
            <label>Popis</label>
            <textarea class="form-control" name="popis" placeholder="popis testu"
                      rows="3">{{ $test->popis ?? old('popis') }}</textarea>
            <small>* nepovinný údaj</small>
            @if($errors->has('popis'))
                @foreach($errors->get('popis') as $message)
                    <div class="invalid-feedback">{{ $message }}</div>
                @endforeach
            @endif
        </div>
    </div>
    <div class="col-6">
        <div class="form-group">
            <label>
                Počet otázok
                <span class="text-red">*</span>
            </label>
            <input class="form-control" type="number" name="pocet_otazok"
                   placeholder="počet otázok vygenerovaného testu"
                   value="{{ $test->pocet_otazok ?? old('pocet_otazok', 5) }}" min=0" required>
            <small>* počet otázok vygenerovaného testu</small>
            @if($errors->has('pocet_otazok'))
                @foreach($errors->get('pocet_otazok') as $message)
                    <div class="invalid-feedback">{{ $message }}</div>
                @endforeach
            @endif
        </div>
    </div>
    <div class="col-6">
        <div class="form-group">
            <label>
                Stav
                <span class="text-red">*</span>
            </label>
            <div class="form-group">
                @foreach(ModelStatusEnum::cases() as $case)
                    <div class="form-check form-check-inline">
                        <input type="radio" class="form-check-input" name="stav" id="public-{{ $loop->index }}"
                               value="{{ $case->value }}"
                               @if($test->stav->equal($case)) checked @endif>
                        <label class="form-check-label" for="public-{{ $loop->index }}">{{ $case->label() }}</label>
                    </div>
                @endforeach
                @if($errors->has('stav'))
                    @foreach($errors->get('stav') as $message)
                        <div class="invalid-feedback">{{ $message }}</div>
                    @endforeach
                @endif
            </div>
        </div>
    </div>
    <div class="col-12">
        <div class="form-group">
            <button class="btn btn-primary" type="submit">
                <i class="fa fa-save"></i>
                Uložiť
            </button>
        </div>
    </div>
</form>