Laravel-Backpack / revise-operation

An admin interface for venturecraft/revisionable - audit log for your Eloquent entries.
Other
42 stars 10 forks source link

[Bug] Select2 in repeatable is lazy loading #25

Open Rian190 opened 11 months ago

Rian190 commented 11 months ago

Bug report

What I did

I added a select2 in a repeatable. And I activated the Model::preventLazyLoading() in the AppServiceProvider

   CRUD::addField([
            'type' => 'repeatable',
            'label' => 'Primary',
            'name' => 'Main',
            'subfields' => [
                [
                    'type' => 'select2',
                    'name' => 'relation',
                    'entity' => 'relation'
                ]
            ]
        ]);

What I expected to happen

The view should load as expected.

What happened

The Illuminate\ Database\ LazyLoadingViolationException exception is thrown

What I've already tried to fix it

??

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 8.2.11 (cli) (built: Oct 6 2023 09:47:18) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.11, Copyright (c) Zend Technologies with Zend OPcache v8.2.11, Copyright (c), by Zend Technologies with Xdebug v3.2.1, Copyright (c) 2002-2023, by Derick Rethans

LARAVEL VERSION:

10.33.0.0

BACKPACK PACKAGE VERSIONS:

backpack/basset: 1.2.2 backpack/crud: 6.3.2 backpack/filemanager: 3.0.6 backpack/generators: v4.0.2 backpack/logmanager: v5.0.1 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.18 backpack/revise-operation: 2.0.0 backpack/settings: 3.1.0 backpack/theme-coreuiv2: 1.2.2

phpfour commented 11 months ago

Hi @Rian190

I have tried to reproduce the issue using our backpack demo but did not encounter it. Here's what I tried:

  1. Called Model::preventLazyLoading() in the AppServiceProvider:

CleanShot 2023-12-09 at 19 56 54

  1. Added a repeatable field in the App\Http\Controllers\Admin\DummyCrudController and commented out everything below it:

CleanShot 2023-12-09 at 19 56 18

  1. Opened up the dummy create form and found it to be working:

CleanShot 2023-12-09 at 19 55 01

Please let us know how we can help you debug this further.

Thanks!