Skip to content

Number field validation message not correct for minimum or maximum values with decimals #1018

Description

@ictbeheer

Describe the bug
When a float is used as maximum or minimum value for a number field, the validation message shows the rounded integer instead of the float value.

To Reproduce
Steps to reproduce the behavior:

  1. Add a number field and set 1.5 as maximum value
  2. Enter 2 in the field
  3. The validation message shows 'Value must be equal to or lower than 1'

Expected behavior
The validation message shows the configured minimum of maximum , e.g. Value must be equal to or lower than 1.5'

Screenshots or Video
N/A

Code

add_action( 'acf/include_fields', function() {
	if ( ! function_exists( 'acf_add_local_field_group' ) ) {
		return;
	}

	acf_add_local_field_group( array(
	'key' => 'group_6a2154b74bf9d',
	'title' => 'Number',
	'fields' => array(
		array(
			'key' => 'field_6a2154b721cf5',
			'label' => 'Number',
			'name' => 'number',
			'aria-label' => '',
			'type' => 'number',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'min' => '',
			'max' => '1.5',
			'allow_in_bindings' => 0,
			'placeholder' => '',
			'step' => '',
			'prepend' => '',
			'append' => '',
		),
	),
	'location' => array(
		array(
			array(
				'param' => 'post_type',
				'operator' => '==',
				'value' => 'page',
			),
		),
	),
	'menu_order' => 0,
	'position' => 'normal',
	'style' => 'default',
	'label_placement' => 'top',
	'instruction_placement' => 'label',
	'hide_on_screen' => '',
	'active' => true,
	'description' => '',
	'show_in_rest' => 0,
	'display_title' => '',
	'allow_ai_access' => false,
	'ai_description' => '',
) );
} );

Version Information:

  • WordPress Version 6.8.5
  • PHP Version: 8.2
  • ACF Version ACF PRO 6.8.2
  • Browser Chrome Version 148.0.7778.216

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions