F
Filamentβ€’2mo ago
Kymset

Header Action use form data

I am trying to make a header action that is a preview within my create and edit forms. So you click it and a modal pops up and shows what it will look like in the front end of my application. I have gotten a custom modal to pop-up and display. The issue I am having is it only uses saved data. Is there a way I can make it use the data from the form. Code I am using within getHeaderActions(): Action::make('preview') ->action(fn (Post $record) => $record->advance()) ->modalContent(fn (Post $record): View => view( 'filament.pages.post.preview', [ 'post' => $record ]))
Solution:
So you want the ownerREcord data, try: modalContent(fn(Post $record, $livewire): then use $livewire->ownerRecord ? but I believe page actions on may have access to the parent so:...
Jump to solution
6 Replies
toeknee
toekneeβ€’2mo ago
Action::make('preview')
->action(fn (Post $record, $data) => $record->advance())
->modalContent(fn (Post $record, $data): View => view(
'filament.pages.post.preview',
[
'post' => $record
]))
Action::make('preview')
->action(fn (Post $record, $data) => $record->advance())
->modalContent(fn (Post $record, $data): View => view(
'filament.pages.post.preview',
[
'post' => $record
]))
Use $data.
Kymset
Kymsetβ€’2mo ago
I have tried using $data and it is returning an empty array
toeknee
toekneeβ€’2mo ago
So data won't return anything from the preview action as you haven't for a form. You get the data form the form on the action, can you explain more or show your entire code.
Kymset
Kymsetβ€’2mo ago
Here is my resource and edit page with header actions
No description
No description
Solution
toeknee
toekneeβ€’2mo ago
So you want the ownerREcord data, try: modalContent(fn(Post $record, $livewire): then use $livewire->ownerRecord ? but I believe page actions on may have access to the parent so: dd($this->form) you should have the updated data
Kymset
Kymsetβ€’2mo ago
If anyone else is looking at this: I needed to modalContent(fn(Post $record, $livewire) Then to get the data I did $livewire->data Thank you @toeknee for the assistance πŸ™‚