Skip to content

Commit 8e04683

Browse files
committed
Highlight filled fields after form submit
1 parent 8dae790 commit 8e04683

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Controllers/TicketsController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,11 @@ public function register_search_fields(Request $request)
924924
$message = trans('panichd::lang.searchform-validation-success', ['num' => count($search_fields)]);
925925
}
926926

927-
return response()->json(['result' => $result, 'messages' => [$message]]);
927+
return response()->json([
928+
'result' => $result,
929+
'messages' => [$message],
930+
'search_fields' => (isset($search_fields) ? array_keys($search_fields) : [])
931+
]);
928932
}
929933

930934
/**

src/Views/tickets/search/scripts.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<script type="text/javascript">
22
// After registering search fields
3-
function success_ajax_callback() {
3+
function success_ajax_callback(response) {
44
// Hide search form
55
$('#search_form').hide();
66
7+
// Clean search form previous filled fields
8+
$('#search_form .form-group.row').removeClass('bg-info');
9+
10+
// Highlight filled fields
11+
$.each(response.search_fields,function(index, value){
12+
$('label[for=' + value + ']').closest('.form-group.row').addClass('bg-info');
13+
});
14+
715
// Load datatable with the new search fields
816
datatable.ajax.reload();
917

0 commit comments

Comments
 (0)