Hide field based on file upload.

Hello, i'm trying to make an option field hidden based on if a file is uploaded in the fileupload component. but when i tried the code below it gives me this error: 'Cannot use empty array elements in arrays' on the reactive function. Is there another approach I can use to hide the option field based on the file upload, or is there a workaround to resolve this issue?
self::getFileUploadComponent(name:'facturen_array', label: 'invoice')->reactive();
Radio::make('type')
->options([
'kasbetaling' => 'kasbetaling',
'credit factuur' => 'credit factuur',
])->label('papertype')->hidden(fn (Closure $get): bool => !$get('facturen_array'));
self::getFileUploadComponent(name:'facturen_array', label: 'invoice')->reactive();
Radio::make('type')
->options([
'kasbetaling' => 'kasbetaling',
'credit factuur' => 'credit factuur',
])->label('papertype')->hidden(fn (Closure $get): bool => !$get('facturen_array'));
2 Replies
Quin.
Quin.14mo ago
try $record
Kyrill71
Kyrill71OP14mo ago
Thank you for your response. Just to clarify, the error I received is related to the ->reactive(); part of my code, not the hidden function. Could you please help me on how to fix the error?
Want results from more Discord servers?
Add your server