Back to default within method

Hi, If I have the following code: Forms\Components\FileUpload::make('image') ->saveUploadedFileUsing(function() { if($get('storage') == 'images') { CODE } }) If the if is not satisfied, how can I get it to do the default method? That is, as if saveUploadedFileUsing has not been defined. My problem is that if the condition is not met, it doesn't work in all other cases. Thanks
3 Replies
LeandroFerreira
LeandroFerreira4mo ago
If you’re customizing this method, it might be better to implement the entire logic. You can check out the default logic here: https://github.com/filamentphp/filament/blob/3.x/packages/forms/src/Components/BaseFileUpload.php
GitHub
filament/packages/forms/src/Components/BaseFileUpload.php at 3.x · ...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
ffffer.
ffffer.OP4mo ago
I understand, but wouldn't it be more convenient that if null is returned for example, it adopts the default behavior? Or that there is some method to avoid these cases in which if there is no real change in behavior, because if I implement the current logic and in a later version the base function is changed, it may not work as expected Thanks for the clarification
awcodes
awcodes4mo ago
If you need this level of functionality you should extend filament’s FileUpload and use you’re own class / field so that you can override the saveUploadedFile at the method level instead allowing you to call parent::saveUploadedFileUsing() as a fallback.
Want results from more Discord servers?
Add your server