Skip to content

Commit

Permalink
Merge pull request #5672 from Laravel-Backpack/fix-save-actions-when-…
Browse files Browse the repository at this point in the history
…all-actions-are-removed

Fix save actions when all actions are removed
  • Loading branch information
pxpm authored Sep 20, 2024
2 parents 9a498cd + be029ad commit 2507ba6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/app/Library/CrudPanel/Traits/SaveActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ public function getSaveAction()
//get only the save actions that pass visibility callback
$saveOptions = $this->getVisibleSaveActions();

if (empty($saveOptions)) {
return [];
}

//get the current action
$saveCurrent = $this->getCurrentSaveAction($saveOptions);

Expand Down
21 changes: 11 additions & 10 deletions src/resources/views/crud/inc/form_save_buttons.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@if(isset($saveAction['active']) && !is_null($saveAction['active']['value']))
<div id="saveActions" class="form-group my-3">
<div id="saveActions" class="form-group my-3">
@if(isset($saveAction['active']) && !is_null($saveAction['active']['value']))

<input type="hidden" name="_save_action" value="{{ $saveAction['active']['value'] }}">

@if(empty($saveAction['options']))
Expand All @@ -23,16 +24,16 @@
</ul>
</div>
@endif
@endif
@if(!$crud->hasOperationSetting('showCancelButton') || $crud->getOperationSetting('showCancelButton') == true)
<a href="{{ $crud->hasAccess('list') ? url($crud->route) : url()->previous() }}" class="btn btn-secondary text-decoration-none"><span class="la la-ban"></span> &nbsp;{{ trans('backpack::crud.cancel') }}</a>
@endif

@if(!$crud->hasOperationSetting('showCancelButton') || $crud->getOperationSetting('showCancelButton') == true)
<a href="{{ $crud->hasAccess('list') ? url($crud->route) : url()->previous() }}" class="btn btn-secondary text-decoration-none"><span class="la la-ban"></span> &nbsp;{{ trans('backpack::crud.cancel') }}</a>
@endif
@if ($crud->get('update.showDeleteButton') && $crud->get('delete.configuration') && $crud->hasAccess('delete'))
<button onclick="confirmAndDeleteEntry()" type="button" class="btn btn-danger float-right float-end"><i class="la la-trash-alt"></i> {{ trans('backpack::crud.delete') }}</button>
@endif
</div>

@if ($crud->get('update.showDeleteButton') && $crud->get('delete.configuration') && $crud->hasAccess('delete'))
<button onclick="confirmAndDeleteEntry()" type="button" class="btn btn-danger float-right float-end"><i class="la la-trash-alt"></i> {{ trans('backpack::crud.delete') }}</button>
@endif
</div>
@endif

@push('after_scripts')
<script>
Expand Down

0 comments on commit 2507ba6

Please sign in to comment.