diff --git a/src/resources/views/crud/form/form_content.blade.php b/src/resources/views/crud/form/form_content.blade.php index ca2a66e..61870fb 100644 --- a/src/resources/views/crud/form/form_content.blade.php +++ b/src/resources/views/crud/form/form_content.blade.php @@ -219,7 +219,7 @@ function preventUnload(event) { @endif $("a[data-toggle='tab']").click(function(){ - currentTabName = $(this).attr('tab_name'); + var currentTabName = $(this).attr('tab_name'); $("input[name='_current_tab']").val(currentTabName); }); diff --git a/src/resources/views/crud/form/show_tabbed_fields.blade.php b/src/resources/views/crud/form/show_tabbed_fields.blade.php index 86a3546..e0bcb6d 100644 --- a/src/resources/views/crud/form/show_tabbed_fields.blade.php +++ b/src/resources/views/crud/form/show_tabbed_fields.blade.php @@ -1,10 +1,18 @@ @php - $horizontalTabs = $crud->getTabsType()=='horizontal' ? true : false; - - if ($errors->any() && array_key_exists(array_keys($errors->messages())[0], $crud->getCurrentFields()) && - array_key_exists('tab', $crud->getCurrentFields()[array_keys($errors->messages())[0]])) { - $tabWithError = ($crud->getCurrentFields()[array_keys($errors->messages())[0]]['tab']); - } + $horizontalTabs = $crud->getTabsType()=='horizontal' ? true : false; + $tabWithError = (function() use ($crud) { + if(! session()->get('errors')) { + return false; + } + foreach(session()->get('errors')->getBags() as $bag => $errorMessages) { + foreach($errorMessages->getMessages() as $fieldName => $messages) { + if(array_key_exists($fieldName, $crud->getCurrentFields()) && array_key_exists('tab', $crud->getCurrentFields()[$fieldName])) { + return $crud->getCurrentFields()[$fieldName]['tab']; + } + } + } + return false; + })(); @endphp @push('crud_fields_styles') @@ -25,13 +33,13 @@ @endpush @if ($crud->getFieldsWithoutATab()->filter(function ($value, $key) { return $value['type'] != 'hidden'; })->count()) -