© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
8 replies
d3v1anX

Saving relationships on livewire Action

Hey guys,

I have a strange situation. I created a livewire component with Filament-Actions.

My action looks like this:
public function createAction(): Action
    {
        return  CreateAction::make('create')
            ->label(__('Add page'))
            ->modalHeading(__('Add a new page'))
            ->modalDescription(__('bla'))
            ->modalSubmitActionLabel(__('Create'))

            ->form([
                TextInput::make('name')
                    ->label(__('Name'))
                    ->required(),
                Grid::make()
                    ->schema([
                        Select::make('status')
                            ->label(__('Status'))
                            ->required()
                            ->options([
                                0 => 'Hidden',
                                1 => 'Visible',
                            ]),

                        Select::make('teams')
                            ->label(__('Teams'))
                            ->required()
                            ->preload()
                            ->multiple()
                            ->searchable()
                            ->relationship('teams', 'name'),
                    ]),

                RichEditor::make('content')
                    ->label(__('Content'))
                    ->required(),

                Hidden::make('sort')
                    ->default(fn () => Page::count() + 1),
            ])
            ->model(Page::class)
            ->action(
                fn (Form $form) => dd($form->getState()) // Getting state - there is no teams relation
            );
    }
public function createAction(): Action
    {
        return  CreateAction::make('create')
            ->label(__('Add page'))
            ->modalHeading(__('Add a new page'))
            ->modalDescription(__('bla'))
            ->modalSubmitActionLabel(__('Create'))

            ->form([
                TextInput::make('name')
                    ->label(__('Name'))
                    ->required(),
                Grid::make()
                    ->schema([
                        Select::make('status')
                            ->label(__('Status'))
                            ->required()
                            ->options([
                                0 => 'Hidden',
                                1 => 'Visible',
                            ]),

                        Select::make('teams')
                            ->label(__('Teams'))
                            ->required()
                            ->preload()
                            ->multiple()
                            ->searchable()
                            ->relationship('teams', 'name'),
                    ]),

                RichEditor::make('content')
                    ->label(__('Content'))
                    ->required(),

                Hidden::make('sort')
                    ->default(fn () => Page::count() + 1),
            ])
            ->model(Page::class)
            ->action(
                fn (Form $form) => dd($form->getState()) // Getting state - there is no teams relation
            );
    }


blade file:
<div>
    {{ $this->createAction }}

    <x-filament-actions::modals />
</div>
<div>
    {{ $this->createAction }}

    <x-filament-actions::modals />
</div>


Problem is, that the "teams" relationship will not be saved and is even not available at $form->getState()
What am I missing? 😮
Solution
->dehydrated()
->dehydrated()
in the select will show it in the
$data
$data
array
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Saving relationships
FilamentFFilament / ❓┊help
11mo ago
How to perform action before saving relationships?
FilamentFFilament / ❓┊help
3y ago
Creating custom livewire action Componente using relationships
FilamentFFilament / ❓┊help
3y ago
livewire action
FilamentFFilament / ❓┊help
2y ago