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

[Bug]: Iam no talbe to use addMenuItemFields select with relationship #41

Open
NifeCz opened this issue Nov 3, 2024 · 3 comments
Open
Labels
bug Something isn't working

Comments

@NifeCz
Copy link

NifeCz commented Nov 3, 2024

What happened?

when you add select with relationship, like eg. linkable_id, there is error Call to a member function isRelation() on null <x-filament-actions::modals />###

How to reproduce the bug

just add in to your AdminPanelProvider plugin
->addMenuItemFields([
Select::make('linkable_id')
->label('Článek')
->relationship('linkable', fn($record) => $record->title)
->preload(),
])

Package Version

0.5.4

PHP Version

.3

Laravel Version

11.9

Which operating systems does with happen with?

Windows

Notes

No response

@NifeCz NifeCz added the bug Something isn't working label Nov 3, 2024
@NifeCz
Copy link
Author

NifeCz commented Nov 3, 2024

thank you for you great work anyway, iam for sure able to fix it on my own

@datlechin
Copy link
Owner

@NifeCz

Because you're trying to use a standard Select component with a MorphTo relationship. When dealing with polymorphic relationships in Filament, you need to use the specialized MorphToSelect component instead.

https://filamentphp.com/docs/3.x/forms/fields/select#handling-morphto-relationships

@NifeCz
Copy link
Author

NifeCz commented Nov 3, 2024

ok, i see, thank you!! but still is not working:

 FilamentMenuBuilderPlugin::make()
                    ->usingResource(MenuResource::class)
                    ->addMenuItemFields([
                        MorphToSelect::make('linkable')
                            ->label('Článek')
                            ->types([
                                MorphToSelect\Type::make(Article::class)
                                    ->titleAttribute('title'),
                            ]),
                    ])

class Article extends Model implements MenuPanelable

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants