How to safely override Filament core components methods?
Hi everyone!
I’ve made a couple of small modifications directly to Filament’s core BaseFileUpload class (in vendor/filament/filament/src/Forms/Components/BaseFileUpload.php), specifically in two methods,
removeUploadedFile(string $fileKey) and reorderUploadedFiles(array $fileKeys), adding this line: $this->callAfterStateUpdated();
I added this call to callAfterStateUpdated() so that my additional logic inside every FileUpload->afterStateUpdated() can run.
The problem is that these changes will be lost if I update or reinstall my Composer dependencies. So, what’s the recommended way to override or hook into these methods without directly modifying Filament core files?
Thank you in advance!
Solution:Jump to solution
Hello
You can Create a new class that extends BaseFileUpload and override the methods up there ...
```
class CustomFileUpload extends BaseFileUpload...
2 Replies