filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.08k stars 2.83k forks source link

$old not avaiable for file uploads #9184

Closed sinnbeck closed 11 months ago

sinnbeck commented 11 months ago

Package

filament/forms

Package Version

v3.0.80

Laravel Version

v10.28.0

Livewire Version

No response

PHP Version

PHP 8.2

Problem description

According to these docs there it is possible to inject $old into afterStateUpdated() to get the previous "state"

https://filamentphp.com/docs/3.x/forms/advanced#field-updates

However when trying to do this with a FileUpload I get the following error

An attempt was made to evaluate a closure for [Filament\Forms\Components\FileUpload], but [$old] was unresolvable.

Expected behavior

I would expect to somehow know what files are uploaded earlier so I know which ones are new

Steps to reproduce

Add this to a file upload form

->afterStateUpdated(function (?array $state, ?array $old) {
      dd($state, $old);
 })

Reproduction repository

https://github.com/sinnbeck

github-actions[bot] commented 11 months ago

Hey @sinnbeck! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.