Skip to content

[5.x]: Dynamic folder paths not creating new folder #15775

@paul-frost

Description

@paul-frost

What happened?

Description

I have an assets field where I want to create a new folder based on 2 data fields of the entry. But if there is no folder with that name the modal window that pops up when you select you want to upload is blank with no upload options. If I create the folder in advance in Assets it works as expected. This is within a Matrix field but I've tried it with in a standalone assets field too.
The code I have been using in Craft 4 is:
{% if owner.startDate %}{owner.startDate|date('Y')}/{owner.startDate|date('Y-m-d')}_{owner.eventTitle|kebab}{%else%}default{%endif%}
I've also tested by just adding a simple 2024 instead of the twig variables, and if there is no existing 2024 folder it fails, see image below.
blank modal

I think this was working before. I'm building a new site (using DDEV locally) and this part was built a month or more ago and I'm pretty sure it was working then. I've just uploaded the site to a staging server and that's when I spotted it not working, and it's not working on my local DDEV either.

Steps to reproduce

  1. Create an Assets field, select 'Restrict assets to a single location' enter a location in the path field that doesn't exist yet.
  2. Go to an entry and select 'Add an asset"
  3. The modal window that pops up is blank with no upload options.

Expected behavior

When you select to upload a file, If the folder name doesn't exist then one is created and the file is put in that folder.

Actual behavior

The modal window that pops up is blank with no upload options.

Craft CMS version

5.4.4

PHP version

8.2

Operating system and version

Linux 6.10.4-linuxkit

Database type and version

Mariadb 10.6

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

  • CKEditor 4.2.0
  • Contact Form 3.1.0
  • Feed Me 6.3.0
  • Image Resizer 4.0.1
  • Maps 5.0.3
  • Obfuscator 1.2.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions