cms
cms copied to clipboard
Getting "This URI has already been taken" when adding elements to a collection
Bug Description
Getting a "This URI has already been taken" message when saving an entry to a specific collection. Have tested a couple other collections and am able to save entries correctly. The collection in question has 27 entries. Permissions look OK. Looked through the content and nothing seems garbled. No publish dates enabled and not orderable, so no tree is being generated.
What I've done so far:
- reverted Statamic as far as 3.1.26, testing on each version
- Removed all the existing entries from collection
- cleared all caches
Any ideas where to start looking?
Environment
Statamic 3.1.29 Pro Laravel 7.30.4 PHP 7.4.19 aryehraber/statamic-captcha 1.5.2 aryehraber/statamic-color-extractor 1.1.2 rias/statamic-data-import 1.1.2 spatie/statamic-responsive-images 2.7.1 webographen/statamic-dynamic-token 1.0.0
Does that collection have a route?
Ahh yes, that was it 😬
Had recently changed the route to {mount}/{id} to get that collection hooked up for a special use-case with the site search. Works great on the front-end, but I guess the CP doesn't like it – maybe there's a different way the route should be written?
Are you getting that validation error just when creating new entries? Or also when editing existing entries?
Looks like just when creating new entries. I can update existing entries, including changing the slug, and it works fine
Cool, I had a feeling. I'm guessing it's because when it tries to validate the uri, it doesn't have an id at that point. Thanks!
I'm in a similar context:
- I have three collections (
Films,Stills,Other) that all have a fieldarchive_uuid archive_uuidis random and auto-generated by Uuid (add-on)- The route on each collection is:
/archive/{archive_uuid}
Question: Will Statamic detect whether the URI is unique when the entries are created?
I ask as although the probability is very low that the same archive_uuid would be created, it'd be nice to know what will happen if that unlikely event occurs.
I'm having this behavior with disabled slug field...
But thanks to the workaround mentioned here https://github.com/statamic/cms/issues/5500 it works now.
I'm going to close this issue now since {id} no longer causes issues in collection routes, thanks to #9035.
Question: Will Statamic detect whether the URI is unique when the entries are created?
Yes, it will do 👍
I'm having this behavior with disabled slug field... But thanks to the workaround mentioned here https://github.com/statamic/cms/issues/5500 it works now.
I'm not sure I completely understand the issue with disabled slug fields. What was your collection route (if you can remember 😆 )?
Glad to hear you found a workaround though.