craftcms / craftcms/cms

Slug based folder structure when not using title field

Open
#14,036 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

Description

I am having an issue with the folder structure in assets in certain scenarios. For certain projects I quite often set the default asset upload location as the {slug} of the the entry to make it a little bit more manageable. I am having an issue on a site currently where I am not using the title field and instead using custom 'firstName' and 'lastName' fields. When I create a new entry and haven't yet saved the entry, any uploaded assets seem to generate a temp folder and get uploaded there instead of under the slug. This is only an issue when not using the title field.

Screenshot 2023-11-16 at 16 13 40

Steps to reproduce
  1. Create a section which uses alternative plain text fields instead of title field
  2. Add an asset field which uses the {slug} as the default folder structure
  3. Create a new entry
  4. Before saving the new entry add an image to the asset field
Additional info
  • Craft version: Craft Pro 4.5.6.1
  • PHP version: 8.1.21
  • Database driver & version: MySQL 8.0.33
  • Plugins & versions:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce this in Craft Pro 4.5.6.1 by creating a section with custom firstName and lastName fields, configuring an asset field with a {slug} folder structure, and uploading an image before saving. Done means the unsaved entry's asset is placed in the intended slug-based folder rather than a temporary folder; compare behavior with a section that uses the title field.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.