Change in `afterStateUpdated()` hook for file uploads?
I have an Image model I'm saving extra data for on upload.
In v2, I got this working using the
afterStateUpdated()
hook: https://github.com/JSn1nj4/ElliotDerhay.com/blob/feature/125-dashboard-overhaul-with-filament/app/Filament/Resources/ImageResource/Pages/CreateImage.php#L27
Reading this other help thread is what got me there: https://discord.com/channels/883083792112300104/1130866560848892015
This worked out so well because the second param was a TemporaryUploadedFile
. It had everything I needed to fill the other fields and locate the file.
Now I'm v3, that second param is just a filename string and I'm having difficulty locating the actual file.
What's the best way to get file info for uploads now?GitHub
ElliotDerhay.com/app/Filament/Resources/ImageResource/Pages/CreateI...
My personal website project. Contribute to JSn1nj4/ElliotDerhay.com development by creating an account on GitHub.
6 Replies
hmmm. I just ran a test on the demo app and $state is returning a
TemporaryUploadedFile
for me.->afterStateUpdated(fn ($state) => dd($state))
Really, with Filament v3?
Is it using Livewire V3 under the hood as well or v2?
If you mean the one from this page, I'll give it a shot and see what I might be missing. Thanks!
https://filamentphp.com/docs/3.x/panels/getting-started#the-demo-project
yea, v3
Filament v3 uses LW3, yes.
@awcodes seems you're right, it's doing it. Something funky must've been happening when I was trying to organize the snippet below in an instance method.
I've decided to just use a plain closure instead of handing off to a method.
Also had to manually set up state fields as described here: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#saving-form-data-to-individual-properties
Now have to figure out why my form fields are apparently not mapping to the model, but this is much bigger progress than I made before.
Thanks!