Error Displaying '[object Object]' in Video Link Field When Switching Upload Options
I have a select field named 'video type,' with two options: 'upload by link' and 'file upload.' When I choose an option, it displays the corresponding field. However, I encounter an issue: when I select 'file upload' and upload a file, and then switch to the 'upload by link' option in the 'video type' field, the 'video link' field displays '[object Object]' in array format. How can I fix this?
Here's my code:
Select::make('video_type')
->reactive()
->options([
"link" => "Upload By Link",
"upload" => "File Upload"
]),
TextInput::make('video_url')
->id('link-field')
->required()
->reactive()
->hidden(fn (Closure $get) => empty($get('video_type')) || $get('video_type') == "upload")
->afterStateHydrated(
function ($state, $component, $record) {
if ($state) {
return $component->state($state);
}
}
),
FileUpload::make('video_url')
->id('upload-field')
->required()
->reactive()
->hidden(fn (Closure $get) => empty($get('video_type')) || $get('video_type') == "link")
->disk('local')
->afterStateHydrated(
function ($state, $component, $record) {
if ($state) {
return $component->state($state);
}
}
),
I want the field name 'video_url' to be used for both file upload and text input, as I intend to store my link in that field.1 Reply
How to fix it ??