Changing decimal place restrictions results in incorrect values persisted to DB
Describe the bug
After having a Supertable field set to 'Number' type with 'Decimal Points' set to zero, and some content saved into that field on some entries, we updated the 'Decimal Points' option to 1. In the editor, the values shows formatted with 1 decimal place, but when saving a new value, it is truncated to an integer.
Example: On the Entry editor page for an Entry which uses this Supertable
- Displayed value: 256.0
- Change value to 512.5
- Save entry
- Reload entry editor page
- Displayed value: 512.0
Additionally, the GraphQL API delivers this field's value as an integer.
Expected: displayed value would be 512.5 (actual 512.0) Expected: value provided via API would be 512.5 (actual 512)
Steps to reproduce
- Create a Supertable and give it a field of type Number
- Set the field's 'Decimal Points' option to 0
- Create a Section and Entry Type that uses this Supertable
- Create an Entry of the new type and enter a value into the Number field
- Save this Entry
- Modify the Supertable field by setting Decimal Points to a non-zero value (tested: 1, 3)
- On the saved Entry, change the value of the Number field to a non-integer value
- Save the Entry again
- Revisit the Entry's editor page.
Expect: Field value to be non-integer and equal to the saved value Actual: Field value is truncated to integer of the saved value
Craft CMS version
4.4.6.1
Plugin version
3.0.81
Multi-site?
No
Additional context
-
This issue does not occur when the field is created with a non-zero number of decimal points from the beginning.
-
Not tested: Creating field with no decimal points and then updating it to non-zero decimal points without saving a value against it on an Entry in between.