Use record ID for file folder path
How would I use the record ID in the folder path to store files?
I have tried the following
but get an error when creating new because the record does not exist yet. It does work if I create the record first then edit as the record already exists.
I have tried the following
but get an error when creating new because the record does not exist yet. It does work if I create the record first then edit as the record already exists.
Solution
I got this working with the following
Only works on the form page not in a modal. Before the data is saved it gets the next available id from the model and then uses that.
In the form I have this
So if you're in the edit screen it works as normal
Only works on the form page not in a modal. Before the data is saved it gets the next available id from the model and then uses that.
In the form I have this
->directory(fn ($record) => $record ? 'project-shapes/' . $record->id : 'project-shapes')So if you're in the edit screen it works as normal