| 
1 |  | -@extends('webfactor::modal.edit_layout')  | 
 | 1 | +@extends('webfactor::modal.save', ['action' => 'edit'])  | 
2 | 2 | 
 
  | 
3 |  | -@section('header')  | 
4 |  | -    <h3 class="box-title">{{ trans('backpack::crud.edit') }} {{ $crud->entity_name }}</h3>  | 
5 |  | -@endsection  | 
6 |  | - | 
7 |  | -@section('content')  | 
8 |  | -    <div class="row">  | 
9 |  | -        <div class="col-md-10 col-md-offset-1">  | 
10 |  | -        @include('crud::inc.grouped_errors')  | 
11 |  | - | 
12 |  | -        <!-- load the view from the application if it exists, otherwise load the one in the package -->  | 
13 |  | -            @if(view()->exists('vendor.backpack.crud.form_content'))  | 
14 |  | -                @include('vendor.backpack.crud.form_content', ['fields' => $fields, 'action' => 'edit'])  | 
15 |  | -            @else  | 
16 |  | -                @include('crud::form_content', ['fields' => $fields, 'action' => 'edit'])  | 
17 |  | -            @endif  | 
18 |  | -        </div>  | 
19 |  | -    </div>  | 
20 |  | -@endsection  | 
21 |  | - | 
22 |  | -@section('footer')  | 
23 |  | -    @include('webfactor::modal.inc.edit_form_save_buttons')  | 
24 |  | -@endsection  | 
25 |  | - | 
26 |  | -@push('crud_fields_scripts')  | 
27 |  | -    <script>  | 
28 |  | -        $("#edit_{{ $entity }}").submit(function (e) {  | 
29 |  | -
  | 
30 |  | -            $.ajax({  | 
31 |  | -                type: "PATCH",  | 
32 |  | -                url: "/{{ ltrim($crud->route . '/ajax', '/') }}",  | 
33 |  | -                data: $("#edit_{{ $entity }}").serialize(), // serializes the form's elements.  | 
34 |  | -                success: function (data) {  | 
35 |  | -                    new PNotify({  | 
36 |  | -                        type: "success",  | 
37 |  | -                        title: "{{ trans('backpack::base.success') }}",  | 
38 |  | -                        text: "{{ trans('backpack::crud.update_success') }}"  | 
39 |  | -                    });  | 
40 |  | -
  | 
41 |  | -                    $("#{{ $entity }}_edit_modal").modal('hide');  | 
42 |  | -
  | 
43 |  | -                    // provide auto-fill  | 
44 |  | -
  | 
45 |  | -                    if ($("#select2_ajax_{{ $request->input('field_name') }}").length) {  | 
46 |  | -                        searchfield = $("#select2_ajax_{{ $request->input('field_name') }}")  | 
47 |  | -                    } else {  | 
48 |  | -                        searchfield = $("#select2_ajax_multiple_{{ $request->input('field_name') }}")  | 
49 |  | -                    }  | 
50 |  | -
  | 
51 |  | -                    searchfield.val(null).trigger('change');  | 
52 |  | -                    searchfield.select2('open');  | 
53 |  | -
  | 
54 |  | -                    // Get the search box within the dropdown or the selection  | 
55 |  | -                    // Dropdown = single, Selection = multiple  | 
56 |  | -                    var search = searchfield.data('select2').dropdown.$search || searchfield.data('select2').selection.$search;  | 
57 |  | -                    // This is undocumented and may change in the future  | 
58 |  | -                    var userInput = $("#edit_{{ $entity }} [name='{{ $request->input('attribute') }}']").serializeArray();  | 
59 |  | -
  | 
60 |  | -                    search.val(userInput[0]['value']);  | 
61 |  | -                    search.trigger('input');  | 
62 |  | -                    setTimeout(function () {  | 
63 |  | -                        $('.select2-results__option').trigger("mouseup");  | 
64 |  | -                    }, 200);  | 
65 |  | -                },  | 
66 |  | -                error: function (data) {  | 
67 |  | -                    new PNotify({  | 
68 |  | -                        type: "error",  | 
69 |  | -                        title: "{{ trans('backpack::base.error') }}",  | 
70 |  | -                        text: "{{ trans('backpack::base.error') }}: " + data.responseJSON  | 
71 |  | -                    });  | 
72 |  | -                }  | 
73 |  | -            });  | 
74 |  | -
  | 
75 |  | -            e.preventDefault(); // avoid to execute the actual submit of the form.  | 
76 |  | -        });  | 
77 |  | -    </script>  | 
78 |  | - | 
79 |  | -@endpush  | 
0 commit comments