{{ Form::open([
    'route' => 'Admin.Shop.Merchandises.store',
    'id' => 'merchandise-form',
    'autocomplete' => 'off',
    'files' => true,
]) }}
<input type="hidden" name="id" id="id" value="{{ $merchandise['id'] ?? false }}">

<div class="row">
    <div class="col-md-8">
        <div class="row mb-3">
            <div class="col-6">
                @include('components.form.input', [
                    'name' => 'name',
                    'value' => $merchandise['name'] ?? null,
                    'required' => true,
                    'label' => 'Nom',
                ])
            </div>
            <div class="col-6">
                @include('components.form.select', [
                    'name' => 'producer_id',
                    'list' => $producers_list ?? [],
                    'value' => $merchandise['producer_id'] ?? null,
                    'class' => 'select2 form-control',
                    'with_empty' => '',
                    'required' => true,
                    'label' => __('Shop.producers.name'),
                ])
            </div>
        </div>

        <div class="row mb-3">
            <div class="col-12">
                @include('components.form.selects.select-tree', [
                    'name' => 'tags[]',
                    'list' => $tags_list,
                    'values' => $merchandise['tags'] ?? null,
                    'class' => 'select2 form-control',
                    'multiple' => true,
                    'label' => 'Tags',
                ])
            </div>
        </div>

        <div class="row mb-3">
            <div class="col-12">
                @include('components.form.textarea', [
                    'name' => 'description',
                    'value' => $merchandise['description'] ?? null,
                    'class' => 'editor',
                    'rows' => 5,
                    'required' => false,
                    'description' => 'Description',
                ])
            </div>
        </div>

        <div class="row mb-3">
            <div class="col-12">
                @include('components.form.textarea', [
                    'name' => 'plus',
                    'value' => $merchandise['plus'] ?? null,
                    'class' => 'editor',
                    'rows' => 5,
                    'required' => false,
                    'label' => 'Son +',
                ])
            </div>
        </div>

    </div>

    <div class="col-md-4">
        @include('components.uploader.widget', [
            'load_url' => route('Admin.Shop.Merchandises.getImages', ['id' => $merchandise['id'] ?? false]),
            'delete_url' => route('Admin.Botanic.Varieties.deleteImage'),
            'name' => 'images',
        ])
    </div>

</div>
{{ Form::close() }}

<x-save />
@include('load.form.appender')
@include('load.form.editor')
@include('load.form.save')
@include('load.form.select2')
@include('load.layout.chevron')
@include('boilerplate::load.fileinput')
@include('boilerplate::load.tinymce')

@push('js')
    {!! JsValidator::formRequest('App\Http\Requests\Admin\Shop\StoreMerchandisePost', '#merchandise-form') !!}
    <script>
        $(function() {
            initSelect2();
            initChevron();
            initEditor();
            initSaveForm('#merchandise-form');
        });
    </script>
@endpush
