Skip to content

[5.x]: Number fields without decimal points still store decimal values #16181

@MoritzLost

Description

@MoritzLost

What happened?

Description

We have a Number field that's set to Decimal Points: 0. Entering a decimal value, like 5.6 will round the value up or down in the Control Panel when the entry is saved, displaying (in this case) 6 in the Control Panel. But in the frontend, the field will still output 5.6 instead of 6.

Steps to reproduce

  1. Create a Number field and set the Decimal Points to 0, leave the rest of the settings at the default.
  2. Add the number field to an entry type.
  3. In any entry of that type, enter a decimal value like 5.6 in the Number field (with the accounts Formatting Locale set to English).
  4. Save the entry. Inspect the value in the entry form in the Control Panel, and output it in a frontend template.

Expected behavior

Decimal values should be rounded up or down upon saving, or display a validation error.

Actual behavior

The Control Panel and frontend output show different values.

Craft CMS version

5.5.1.1

PHP version

8.3

Operating system and version

No response

Database type and version

MySQL 8

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions