statamic / cms

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

Field automatic handle generation doesn't slugify dash characters #10533

Closed sjclark closed 2 months ago

sjclark commented 2 months ago

Bug description

Statamics automagical creation of field handle's from Display Labels doesn't properly convert dashes to underscores, as required to pass Statamics own validation requirements.

Screenshot 2024-07-31 at 4 21 56 pm

I feel like this behavior should be adjusted to underscorify any dash characters.

How to reproduce

  1. Open any interface to make fields
  2. Type in a Display Label with a dash in the value (say "JSON-LD")
  3. Try and save with the default generated handle (json-ld)
  4. Fail miserably, resort to drinking.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.17.0
PHP Version: 8.2.21
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: complaints.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

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

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

Statamic
Addons: 1
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.17.1 PRO

Statamic Addons
jacksleight/statamic-bard-mutator: 2.3.1

Installation

Fresh statamic/statamic site via CLI

Additional details

Just as a sidenote..... Statamic converts $ to usd, which is interesting (but not problematic) - curious that it does no conversion of any other non-numeric characters. 😄

sjclark commented 2 months ago

Seems to work correctly the few others places I've checked;

Screenshot 2024-07-31 at 5 25 20 pm

jasonvarga commented 2 months ago

I initially misunderstood what this issue was about. I thought you were talking about the brackets being converted to underscores. I also saw your currency problem. Both are fixed in #10538. Oh well, doesn't hurt to have them done.

We'll get to the real issue separately. 😊