© 2026 Hedgehog Software, LLC

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

How to prefill resource field and run some calculations

I have an Invoices resource that has an action redirecting to the Credit Notes resource passing the invoice_id parameter:

->action(fn($record) =>redirect()
   ->route('filament.admin.resources.credit-note.create', 
      ['invoice_id' => $record->id ])
    ),
->action(fn($record) =>redirect()
   ->route('filament.admin.resources.credit-note.create', 
      ['invoice_id' => $record->id ])
    ),


This is working file. In the Credit Notes resource I'm using default() to load that.

Select::make('invoice_id')
   ->default(fn() => request()->get('invoice_id'))
Select::make('invoice_id')
   ->default(fn() => request()->get('invoice_id'))


But when using normally, this select field does some calculations using the afterStateUpdate() method, calculating some totals and setting those values into other fields.

My issue is that when prefilling the field using default(), those calculations are not triggered. I guess the afterStateUpdated doesn't run at that point.

Is there a way to trigger the afterStateUpdated from the default() method? Or some other solution I'm not seeing?
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

Prefill field
FilamentFFilament / ❓┊help
3y ago
"Create another" and prefill field
FilamentFFilament / ❓┊help
3y ago
Prefill field with Get
FilamentFFilament / ❓┊help
2y ago
How to prefill a TextInput on the create resource form?
FilamentFFilament / ❓┊help
2y ago