is it possible to disable form while image is uploading?

the field state goes uncompleted after image upload. is there any way to disable the form while image is uploading?
Solution:
@Leandro Ferreira Your hint was helpful. I solved it this way: ```php ...
Jump to solution
6 Replies
LeandroFerreira
LeandroFerreira12mo ago
->extraAlpineAttributes([':disabled' => 'isUploadingFile'])
->extraAlpineAttributes([':disabled' => 'isUploadingFile'])
KiaBoluki
KiaBoluki12mo ago
@Leandro Ferreira Thanks for reply. but the form doesn't have this method. I need to add this method to all fields in the form.
Call to undefined method Filament\Resources\Form::extraAlpineAttributes()
LeandroFerreira
LeandroFerreira12mo ago
actually you can use this method by field TextInput::make('title')->extraAlpineAttributes([':disabled' => 'isUploadingFile'])
KiaBoluki
KiaBoluki12mo ago
Yeah, it works by field. However, I'm curious to find a way to disable the form while the form is uploading file. Perhaps a trait for all models would be nice to achieve this. You know, I have a lot of forms and fields in the app.
LeandroFerreira
LeandroFerreira12mo ago
not sure if it is the right way to do that but you can use configureUsing to apply global settings https://filamentphp.com/docs/2.x/forms/fields#global-settings
Filament
Fields - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
Solution
KiaBoluki
KiaBoluki12mo ago
@Leandro Ferreira Your hint was helpful. I solved it this way:
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Filament\Forms\Components\Component;

class FilamentProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
Component::configureUsing(function (Component $component){
if ( method_exists($component::class , 'extraAlpineAttributes' ) )

$component->extraAlpineAttributes([':disabled' => 'isUploadingFile']);

});
}
}
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Filament\Forms\Components\Component;

class FilamentProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
//
}

/**
* Bootstrap services.
*/
public function boot(): void
{
Component::configureUsing(function (Component $component){
if ( method_exists($component::class , 'extraAlpineAttributes' ) )

$component->extraAlpineAttributes([':disabled' => 'isUploadingFile']);

});
}
}
I am not sure if it is the best practice . but it seems works. thank you.