Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I cannot use belongsTo fields with in a Dependency container? #31

Open
StaffCollab opened this issue Mar 16, 2023 · 6 comments
Open

I cannot use belongsTo fields with in a Dependency container? #31

StaffCollab opened this issue Mar 16, 2023 · 6 comments

Comments

@StaffCollab
Copy link

Here is my code.

            DependencyContainer::make([
            BelongsTo::make('Event Place Private')->showCreateRelationButton()
            ])->dependsOnIn('eventPlaceType.id', [3,4,5]),

the belongsTo dropdown does toggle based on the parent, but there is no data in the dropdown??

@adin00
Copy link

adin00 commented May 5, 2023

Until it gets fixed here's a quick'n'dirty workaround (without the create relation option):

      DependencyContainer::make([
        Select::make('Related Model', 'related_id')
          ->searchable()
          ->options(
            RelatedModel::all(['id', 'name'])
              ->mapWithKeys(fn ($m) =>  [$m->id => $m->name])
          ),
      ])->dependsOnIn('eventPlaceType.id', [3,4,5]),

@Slgoetz
Copy link

Slgoetz commented Jun 28, 2023

Any update on if this bug will actually be fixed

@Anticom
Copy link

Anticom commented Oct 3, 2023

If I could receive any hints on what the actual issue is, I'm more than happy to provide a PR!

@yllndritb
Copy link

yllndritb commented Apr 9, 2024

The issue here is it will not show any options in the list of BelongsTo relationships (the list will appear empty) and also search will not work @Anticom

@devsquadcore
Copy link

devsquadcore commented Apr 18, 2024

hi
any updates for BelongsTo? I need something like

DependencyContainer::make([
            BelongsTo::make('Based on (one git project)', 'basedOnProject', '\App\Nova\Projects')
                ->hideFromIndex()->searchable()->nullable()->dontReorderAssociatables()
                ->hideFromDetail(function () use ($request) {
                    if ($this->basedOnId > 0 && $this->redirectUrl == '') return false;
                    else return true;
                })
        ])->dependsOnEmpty('redirectUrl');

redirectUrl is string field

But this code not work (see 404 when try to add/edit resource)

@dalmarcolucas
Copy link

yeah, this still happens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants