Edit: should have started with this, but I picked apart a request in my actual project just now, and realized the empty + hidden field is actually being included in the payload. Maybe that's the issue—that a hidden field is being passed through in the first place, for the custom fieldtype config? 🤔
When building out the configFieldItems in a custom field, I think any (but at minimum the numeric) fieldtypes that have an inherent/preset $rules, together with a user-defined sometimes validation rule, will always throw errors (when they're not submitted). Pretty sure the preset $rules, in this context, is overriding or taking precedence over (ie, evaluated before) the sometimes rule. From Floatval, for example:
Click into the Field with Replicator Field (at the bottom)
Hit Apply without making any changes (should get validation errors)
Toggle on the Root Toggle
See the Must be an integer. error on the Sometimes Float Field
Inspect FieldWithReplicator.php, line 17, to make sure I'm not missing something obvious. 😬
Logs
No response
Environment
<details>
<summary>Environment</summary>
Application Name: Statamic
Laravel Version: 10.43.0
PHP Version: 8.2.5
Composer Version: 2.5.4
Environment: local
Debug Mode: ENABLED
URL: localhost
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: 0
Antlers: runtime
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.48.0 Solo
</details>
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
None
Additional details
I initially thought this was related to nested fields (ie, in a Replicator)—hence that setup in the blueprint. Left it in there because it does also impact nested numerics...but it's not specific to that context, which is why I didn't emphasize it above.
Let me know if there's anything else I can do to help, here!
Bug description
Edit: should have started with this, but I picked apart a request in my actual project just now, and realized the empty + hidden field is actually being included in the payload. Maybe that's the issue—that a hidden field is being passed through in the first place, for the custom fieldtype config? 🤔
When building out the
configFieldItems
in a custom field, I think any (but at minimum thenumeric
) fieldtypes that have an inherent/preset$rules
, together with a user-definedsometimes
validation rule, will always throw errors (when they're not submitted). Pretty sure the preset$rules
, in this context, is overriding or taking precedence over (ie, evaluated before) thesometimes
rule. FromFloatval
, for example:Here's a repo that reproduces the issue, and a screencap of what this looks like with a bit of code + CP interface:
How to reproduce
Field with Replicator Field
(at the bottom)Root Toggle
Sometimes Float Field
FieldWithReplicator.php
, line 17, to make sure I'm not missing something obvious. 😬Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
None
Additional details
I initially thought this was related to nested fields (ie, in a Replicator)—hence that setup in the blueprint. Left it in there because it does also impact nested numerics...but it's not specific to that context, which is why I didn't emphasize it above.
Let me know if there's anything else I can do to help, here!