Have you seen our video tutorials? Check 'em out!

file-field_type - default upload folder

huglester - 2 months ago

Hello,

is there a way to set up default upload folder via config? For some modules, I would like to auto-create folders on install (for example), and if user picks to upload - it would automatically upload to folder like "cookiesforsale"

Thank you

ryanthompson - 2 months ago

If you define only 1 folder it will skip the selection of it - so in your case I think you could use a builder override to override the fields config on runtime.

ExampleFormFields
{
    public function (ExampleFormBuilder $builder) {
        $builder->setFields([
            '*',
            'upload_field' => [
                 'config' => [
                    'folders' => 'you_custom_folder'
                 ]
            ]
        ]);
    }
}

Then you could add any custom logic to this you wanted - like defining the module's folder.