Bug description
Setting a code field to required has no effect. An empty field passes validation and allows saving the entry.
The payload sent from the fieldtype is an object, with the actual code value in a nested key. Submitting an empty field produces an object like this, which passes validation:
{ code: null, mode: 'application/ld+json'}
Ideally the code fieldtype could only send the object if a value is present, and plain null if not.
How to reproduce
Add a required code field to an entry blueprint.
-
handle: json_ld
field:
type: code
mode: 'application/ld+json'
validate:
- required
Create an entry and submit with the code field empty.
Logs
Environment
Environment
Laravel Version: 13.17.0
PHP Version: 8.4.20
Composer Version: 2.8.3
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: Europe/Vienna
Locale: en
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / daily
Mail: log
Queue: database
Session: file
Storage
public/storage: NOT LINKED
Statamic
Addons: 11
License Key: Not set
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 6.23.0 PRO
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Bug description
Setting a
codefield torequiredhas no effect. An empty field passes validation and allows saving the entry.The payload sent from the fieldtype is an object, with the actual code value in a nested key. Submitting an empty field produces an object like this, which passes validation:
Ideally the code fieldtype could only send the object if a value is present, and plain
nullif not.How to reproduce
Add a required code field to an entry blueprint.
- handle: json_ld field: type: code mode: 'application/ld+json' validate: - requiredCreate an entry and submit with the code field empty.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response