guiiamorim
Can't change disabled state on fileupload
I have two fileupload fields in a form, the second is dependant on the first. I made the first input live só the form re-renders but the second input still is disabled. Is there a way to make it change it's state?
Forms\Components\FileUpload::make('cert_file')
->disk('s3')
->required(fn(Forms\Get $get): bool => $this->isCertificateRequired($get('api')))
->live()
->visibility('private')
->directory('certificates')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file, RelationManager $livewire): string {
return (string)str($file->getClientOriginalName())
->prepend($livewire->ownerRecord->id . '-');
})
->label('Certificado'),
Forms\Components\FileUpload::make('cert_key')
->disk('s3')
->nullable()
->disabled(fn(Forms\Get $get): bool => !filled($get('cert_file')))
->visibility('private')
->directory('certificates')
->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file, RelationManager $livewire): string {
return (string)str($file->getClientOriginalName())
->prepend($livewire->ownerRecord->id . '-');
})
->label('Chave privada'),
2 replies