Skip to content

Entries without slugs cannot be created in collections where slugs are not required but some blueprints have them. #11593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
finnjsmith opened this issue Mar 19, 2025 · 0 comments

Comments

@finnjsmith
Copy link

finnjsmith commented Mar 19, 2025

Bug description

I had a collection where entries did not require slugs called functional_pages that was working just fine before I added a third blueprint. The existing blueprints focussed around templating 404 pages and search results pages.

When I created a blueprint, I added a slug field in the sidebar section and was able to get entries using said blueprint to appear in my browser just fine. When I was testing adding new entries using one of the older 2 blueprints, I was met with this error in my network response:

{
    "message": "The given data was invalid.",
    "errors": {
        "slug": [
            "This URI has already been taken."
        ]
    }
}

I checked the entries that already existed, and they did not contain slug or URI data and I was able to edit these in the control panel with no issues. I'm puzzled because the collection's "require slugs" option is definitely switched off, although I did have to add a route pattern when adding the notorious third blueprint: {parent_uri}/{slug}.

It appears to be that when setting a route pattern in a collection, the slug field is sent in the payload of the request:

{"title":"International 404 Page","slug":null,"published":false,"single_column_content":['redacted_due_to_length'],"_blueprint":"404_page"}

I feel as though it should be possible to have entries that do and don't contain slugs in the same collection. If this is not a bug then I feel it should be documented somewhere in the collections page of the docs.

How to reproduce

  • Create a collection
    • ensure that slugs are not required
    • ensure there is a route pattern
  • Create a blueprint that does not contain a slug field
  • Create a blueprint that does contain a slug field
  • you will be able to create new entries using the blueprint with a slug, but not using the one without

Logs

Environment

Environment
Application Name: Laravel
Laravel Version: 11.44.2
PHP Version: 8.3.17
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: statamic-project.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / single, bugsnag
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 7
Sites: 13 (International, Australia, Belgium, and 10 more)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.51.0 PRO

Statamic Addons
alt-design/alt-seo: 1.2.4
anakadote/statamic-recaptcha: 1.0.18
mitydigital/sitemapamic: 3.2.0
rias/statamic-redirect: 3.9.3
statamic/eloquent-driver: 4.20.2
thoughtco/statamic-restrict-fields: 1.1.0
transformstudios/review: 5.0.1

Statamic Eloquent Driver
Asset Containers: file
Assets: file
Blueprints: file
Collection Trees: eloquent
Collections: file
Entries: eloquent
Forms: eloquent
Global Sets: file
Global Variables: eloquent
Navigation Trees: file
Navigations: file
Revisions: eloquent
Sites: file
Taxonomies: file
Terms: eloquent
Tokens: file

Installation

Fresh statamic/statamic site via CLI

Additional details

There are 13 sites in this project, so I've had to grapple with a lot of multi-site features in order to get things working in a certain way. For example I'm hiding the localisation menu so that users cannot translate pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant