AdvancedCustomFields / AdvancedCustomFields/acf
Number field validation message not correct for minimum or maximum values with decimals
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
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:
- Add a number field and set 1.5 as maximum value
- Enter 2 in the field
- 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the number-field validation with a maximum of 1.5 and an entered value of 2, then locate the code that formats minimum and maximum validation messages. Confirm that the configured decimal is retained in the message and verify the same behavior for minimum values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100