© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Robin

Dynamic save for form relation ship

Hi,

I wonder how I can make sure that the relationship gets "saved" but still keep reactivity to handle another task. How can I achieve this?

Example code:
 Fieldset::make('Power')
    ->relationship('state')
    ->schema([
        Select::make('requested_power')->label('Power input request')
            ->reactive()
            ->afterStateUpdated(function (?Model $record, $state) {
                /* @var Device $record */
                $this->getMQTTBroker()->publish(new SetInputPowerMessage($record, $state));
            })
            ->options([
                '0' => 'Fixed 5V@5A',
                '1' => 'Fixed 9V@5A',
                '2' => 'Fixed 12V@5A',
                '3' => 'Fixed 15V@5A',
                '4' => 'Fixed 20V@5A',
            ]),
])->columns(3),
 Fieldset::make('Power')
    ->relationship('state')
    ->schema([
        Select::make('requested_power')->label('Power input request')
            ->reactive()
            ->afterStateUpdated(function (?Model $record, $state) {
                /* @var Device $record */
                $this->getMQTTBroker()->publish(new SetInputPowerMessage($record, $state));
            })
            ->options([
                '0' => 'Fixed 5V@5A',
                '1' => 'Fixed 9V@5A',
                '2' => 'Fixed 12V@5A',
                '3' => 'Fixed 15V@5A',
                '4' => 'Fixed 20V@5A',
            ]),
])->columns(3),


I also want to get the record, not the relation inside the
afterStateUpdated
afterStateUpdated
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

relation ship undefined method
FilamentFFilament / ❓┊help
3y ago
dynamic colspan for resource form
FilamentFFilament / ❓┊help
2y ago
Dynamic form for product prices
FilamentFFilament / ❓┊help
2y ago
How to use a Repeater with relation ship in an actions form?
FilamentFFilament / ❓┊help
2y ago