<script>
    $(() => {
        $(".btn-save").on('click', function(e) {
            e.preventDefault();

            $("#formCategory").parsley().validate();

            if ($("#formCategory").parsley().isValid()) {
                $("#formCategory").trigger('submit');
            }
        });
    });
</script>
<x-modal-layout class="modal-dialog-centered modal-xl">
    <x-forms.form method="POST" action="{{ $method }}" id="formCategory" onsubmit="btnLoading('{!! __('messages.saving_state') !!}')" autocomplete="off" enctype="multipart/form-data" data-parsley-validate="">
        @csrf
        <x-forms.form-help :mode="$updateMode" />
        <div class="row">
            <div class="col-md-12">
                <div class="mb-2">
                    <x-forms.label for="name" :value="__('lang.name')" /><span class="asterisk">*</span>
                    <input id="name" type="text" class="form-control" name="name" value="{{ ($Category == TRUE)? $Category->name : old('name') }}" placeholder="@lang('lang.place_data', ['data' => __('lang.name')])" required/>
                </div>
                <div class="mb-2">
                    <x-forms.label for="slug" :value="__('lang.slug')" /><span class="asterisk">*</span>
                    <input id="slug" type="text" class="form-control" name="slug" value="{{ ($Category == TRUE)? $Category->slug : old('slug') }}" placeholder="@lang('lang.place_data', ['data' => __('lang.slug')])" required/>
                </div>
                <div class="mb-2">
                    <x-forms.label for="status" :value="__('lang.status')" /><span class="asterisk">*</span>
                     <select class="form-control" name="status" id="status" required>
                        <option value="" selected>{{ __('messages.select_data', ['data' => __('lang.status'),]) }}</option>
                        <option value="Y" @if ($Category == TRUE) {{ 'Y' == $Category->status ? 'selected' : '' }} @endif>{{ __('lang.yes')}}</option>
                        <option value="T" @if ($Category == TRUE) {{ 'T' == $Category->status ? 'selected' : '' }} @endif>{{ __('lang.no')}}</option>
                    </select>
                </div>
            </div>
        </div>
    </x-forms.form>
    <x-slot name="footer">
        <button class="btn btn-primary btn-loading btn-save">{{ __('lang.save') }}</button>
    </x-slot>
</x-modal-layout>
