Skip to content

[Bug] Translatable + Dropdown buttons do not work together #5846

@tabacitu

Description

@tabacitu

Bug report

Please note: All issues must be submitted in English. If not, they will be closed automatically.

What I did

In a project @maurohmartinez had to use two of our features together:

  • multi-language entities
  • CRUD dropdown buttons

What I expected to happen

Dropdown buttons to incorporate the Edit functionality.

What happened

Not that - they broke.

What I've already tried to fix it

Mauro has fixed them this way in the project. Can't say it's final because:

  • when the dropdown is open, it pushes the Delete button off the dropdown;
  • when the dropdown is not enabled, it make the whole CRUD look weird (it's maybe display block?!)

But it's a place to start!

CleanShot.2025-08-06.at.08.58.57.mp4

resources/views/vendor/backpack/crud/buttons/show.blade.php:

@if ($crud->hasAccess('show', $entry))
    @if (!$crud->model->translationEnabled() || !\App\Services\LocalizationService::supportsMultipleLocales())
        <a href="{{ url($crud->route.'/'.$entry->getKey().'/show') }}" bp-button="show" class="btn btn-sm btn-link">
            <i class="la la-eye"></i> <span>{{ trans('backpack::crud.preview') }}</span>
        </a>
    @else
        <div>
            <a class="btn btn-sm btn-link dropdown-toggle text-primary pl-1" data-toggle="dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                {{ trans('backpack::crud.preview') }} <span class="caret"></span>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="dropdown-header">{{ trans('backpack::crud.preview') }}:</li>
                @foreach ($crud->model->getAvailableLocales() as $key => $locale)
                    <a class="dropdown-item" href="{{ url($crud->route.'/'.$entry->getKey().'/show') }}?_locale={{ $key }}">{{ $locale }}</a>
                @endforeach
            </ul>
        </div>
    @endif
@endif

resources/views/vendor/backpack/crud/buttons/update.blade.php:

@if ($crud->hasAccess('update', $entry))
    @if (!$crud->model->translationEnabled() || !\App\Services\LocalizationService::supportsMultipleLocales())
        <a href="{{ url($crud->route.'/'.$entry->getKey().'/edit') }}" bp-button="update" class="btn btn-sm btn-link">
            <i class="la la-edit"></i> <span>{{ trans('backpack::crud.edit') }}</span>
        </a>
    @else
        <div>
            <a class="btn btn-sm btn-link dropdown-toggle text-primary pl-1" data-toggle="dropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                {{ trans('backpack::crud.edit') }} <span class="caret"></span>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="dropdown-header">{{ trans('backpack::crud.edit_translations') }}:</li>
                @foreach ($crud->model->getAvailableLocales() as $key => $locale)
                    <a class="dropdown-item" href="{{ url($crud->route.'/'.$entry->getKey().'/edit') }}?_locale={{ $key }}">{{ $locale }}</a>
                @endforeach
            </ul>
        </div>
    @endif
@endif

Is it a bug in the latest version of Backpack?

This is a bug in Backpack v6 latest yes.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Todo

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions