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),


I also want to get the record, not the relation inside the afterStateUpdated
Was this page helpful?