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

Selected option from relation doesn't get passed to action callback in custom modal #11870

Closed
webmasterlv opened this issue Mar 15, 2024 · 1 comment
Labels
bug Something isn't working low priority unconfirmed

Comments

@webmasterlv
Copy link

Package

filament/filament

Package Version

v3.2.50

Laravel Version

v10.48.3

Livewire Version

v3.4.9.

PHP Version

8.2

Problem description

I want to create button in the top header of the Resource. I added new action in getHeaderActions() of the ListRecords class. There is a textarea and a dropdown. The dropdown is of Forms\Components\Select and configured to use relationship:

Action::make('AddRelation')
    ->form([
        Forms\Components\Textarea::make('text')
            ->required(),

        Forms\Components\Select::make('relation_id')
            ->relationship('relationship', 'name')
            ->preload()
            ->multiple()
            ->maxItems(1)
    ])
    ->action(function (array $data): void {
        //`text` is here, but `relation_id` is not.
        dd($data);
})

Expected behavior

action() should receive all user entered form data regardless of the input type.

Steps to reproduce

  • Setup environmet
  • composer install
  • php artisan migrate
  • php artisan db:seed
  • php artisan make:filament-user - create user as requested
  • Log into panel, navigate to "Relations"
  • Click on "Add test"
  • Fill the form and submit. You can see that there only will be data from textarea.

Reproduction repository

https://github.com/webmasterlv/filament-test.git

Relevant log output

No response

@webmasterlv webmasterlv added bug Something isn't working low priority unconfirmed labels Mar 15, 2024
@danharrin
Copy link
Member

Form components using relationship() are designed not to dehydrate into $data so that you can save that data to the main model out of the box. When calling ->saveRelationships() or when your action is associated with a record, it will save the data for you.

If you add ->dehydrated() onto that Select after ->relationship(), it should work.

@danharrin danharrin closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low priority unconfirmed
Projects
Status: Done
Development

No branches or pull requests

2 participants