© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
gladjanus43

Save form before calling a header action

Hi,

I have a resource with a repeater inside of it. I want the user to easily add tariffs to the order and when they are done adding the tariffs, they should hit the send offer button.
This then sends out an email to the customer with the just added tariff information.

However ofcourse the form is not yet saved through the save form button. The tariffs are therefore not saved to the database. I have tried a lot, and can retrieve the data through the livewire component. But my issue is that I then need to manually update all the fields of the order, and of the order tariffs. Is there a way to instantly save the entire form and then proceed with my custom action?

This is my current action:
Action::make('Send Offer')
                ->requiresConfirmation()
                ->icon('heroicon-o-envelope')
                ->action(function (TransportOrder $record, Component $livewire) {
                    $livewire->validate();
                    $record->update([
                        'status' => 'ACCEPTED_INTERNAL',
                    ]);
                    Mail::to($record->user->email)->send(new TransportOfferSend($record));
                    $this->refreshFormData([
                        'status',
                    ]);

                    Notification::make()
                        ->title('Offer send')
                        ->body('Offer send to the customer')
                        ->success()
                        ->send();
                })
                ->color('success')
Action::make('Send Offer')
                ->requiresConfirmation()
                ->icon('heroicon-o-envelope')
                ->action(function (TransportOrder $record, Component $livewire) {
                    $livewire->validate();
                    $record->update([
                        'status' => 'ACCEPTED_INTERNAL',
                    ]);
                    Mail::to($record->user->email)->send(new TransportOfferSend($record));
                    $this->refreshFormData([
                        'status',
                    ]);

                    Notification::make()
                        ->title('Offer send')
                        ->body('Offer send to the customer')
                        ->success()
                        ->send();
                })
                ->color('success')
Screenshot_2023-12-08_at_15.13.59.png
Solution
Solution was quite simple. Just call $this->save inside the action function. It will then save the form...

Action::make('Send Offer')
  ->requiresConfirmation()
  ->icon('heroicon-o-envelope')
  
  ->action(function (TransportOrder $record) {
      $this->save();
}
Action::make('Send Offer')
  ->requiresConfirmation()
  ->icon('heroicon-o-envelope')
  
  ->action(function (TransportOrder $record) {
      $this->save();
}
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

Save form from a header action
FilamentFFilament / ❓┊help
16mo ago
Save form before running action
FilamentFFilament / ❓┊help
3y ago
Add header Form action buttons
FilamentFFilament / ❓┊help
13mo ago
Header Action use form data
FilamentFFilament / ❓┊help
2y ago