statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.03k stars 530 forks source link

Issues with `title_format` and slugs #7373

Open aerni opened 1 year ago

aerni commented 1 year ago

Bug description

If you are generating an entry's title using the collection's title_format option, the slug is only updated after the entry is saved. This is leading to the issue illustrated in the video.

It would be a nice UX improvement if the title would generate on the fly and not only after saving the entry. This would also make the slug generate in real-time as it usually does. And would probably solve this issue altogether.

https://user-images.githubusercontent.com/23167701/213204712-dc18fc61-3ffe-42d3-80a2-fbd8ec177545.mov

How to reproduce

  1. Add a first_name and last_name field to your blueprint
  2. Add title_format: '{first_name} {last_name}' to your collection config
  3. Make the slug generate from the title:
    handle: slug
    field:
    type: slug
    from: title
    generate: true

Logs

No response

Environment

Environment
Application Name: gomagazin
Laravel Version: 9.47.0
PHP Version: 8.1.13
Composer Version: 2.5.0
Environment: local
Debug Mode: ENABLED
URL: gomagazin.test
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 9
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.3.64 PRO

Statamic Addons
aerni/advanced-seo: 1.3.3
aerni/livewire-forms: 6.3.0
aerni/social-links: 3.0.3
aryehraber/statamic-impersonator: 2.4.1
jacksleight/statamic-bard-mutator: 1.1.3
jacksleight/statamic-bard-texstyle: 1.0.3
jonassiewertsen/statamic-livewire: 2.9.0
spatie/statamic-responsive-images: 2.15.1
visuellverstehen/statamic-classify: 2.4.0

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

runtime (new)

Additional details

No response

jasonvarga commented 1 year ago

Could you make the slug read only too?

aerni commented 1 year ago

In most cases, that wouldn't be a problem. But in this example, multiple people might have the same name. So the slug needs to be editable.