Dependent file upload option based on select field in form

I need to have a different directory for an file upload field based on a selected option: so I have an option in a select field:
Select::make('first')
->options([
'one' => 'One',
'two' => 'Two',
'three' => 'Three',
])
->live(),

FileUpload::make('second')
->disk('s3')
->directory('download' . '/' . <here-will-be-one-two-or-three>)
Select::make('first')
->options([
'one' => 'One',
'two' => 'Two',
'three' => 'Three',
])
->live(),

FileUpload::make('second')
->disk('s3')
->directory('download' . '/' . <here-will-be-one-two-or-three>)
How to add one or two or three instead of here-will-be-one-two-or-three placeholder based on what I select in the 'first' select box? Basically, I want to store the file in different folders based on what the user selects in options of select box.
1 Reply
Wirkhof
Wirkhof4mo ago
Can I put some function in the ->directory() that would query to currently selected option in the selectbox? How to access the currently selected value from the selectbox field inside ->directory() in the FileUpload field?