Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.16k stars 893 forks source link

[Bug] InlineCreate doesnt work #5405

Closed k-wiese closed 10 months ago

k-wiese commented 10 months ago

Bug report

What I did

I've set up inlineCreate operation in my OfficeCrudController (secondary), and also in my VisitCrudController ive setup the field for inlinecreate, the relationships are working fine.

VisitCrudController setupCreateOperation:
    protected function setupCreateOperation()
    {
        CRUD::setValidation(VisitRequest::class);
        CRUD::addField([
            'label' => 'Office',
            'type' => 'select2_from_ajax',
            'name' => 'office_id',
            'entity' => 'office',
            'model' => "App\Models\Office",
            'attribute' => 'name',
            'attributes' => [
                'data-placeholder' => 'Select office',
            ],
            'minimum_input_length' => 3,
            'data_source' => route('visit.office-search-data'),
            'inline_create' => ['entity' => 'office'], // Enable inline create
            'relationship' => [
                'name' => 'office',
                'entity' => 'office', 
            ],
        ]);
    }

    //Visit relationship:

        public function office(): BelongsTo
    {
        return $this->belongsTo(Office::class);
    }

Office crud controller:

*/ class OfficeCrudController extends CrudController { use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\InlineCreateOperation;

//relationship:

public function visits(): HasMany
{
    return $this->hasMany(Visit::class);
}

What I expected to happen

I expected the +Add inline create button to show up.

What happened

The button doesnt show up.

What I've already tried to fix it

I've checked if everything was setup fine, and consulted gpt in many aspects.

Is it a bug in the latest version of Backpack?

Yes.

Backpack, Laravel, PHP, DB version

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

PHP VERSION:

PHP 8.1.10 (cli) (built: Aug 30 2022 18:05:49) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.1.10, Copyright (c) Zend Technologies

LARAVEL VERSION:

10.37.3.0

BACKPACK PACKAGE VERSIONS:

backpack/activity-log: 2.0.1 backpack/basset: 1.2.2 backpack/crud: 6.4.2 backpack/filemanager: 3.0.6 backpack/generators: v4.0.2 backpack/permissionmanager: 7.1.1 backpack/pro: 2.0.20 backpack/theme-tabler: 1.1.2

welcome[bot] commented 10 months ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

k-wiese commented 10 months ago

nevermind, sorry the type should be:

'type' => "relationship",

jcastroa87 commented 10 months ago

Hello @k-wiese as i understand is working for you now, right?

Cheers.

jcastroa87 commented 10 months ago

Hello @k-wiese given your response and due to lack of activity I will close this issue. If the problem persists, you can reopen it or create a new one.

Cheers.