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:Jump to 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:...
6 Replies
Use $data.
I have tried using $data and it is returning an empty array
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.
Here is my resource and edit page with header actions
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:
dd($this->form) you should have the updated data
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 π