On the form element, how do I allow the number field to validate a number with two decimal places? Currently, it will only validate whole numbers, and won’t submit if there are decimal places in it.
1 Like
I need to collect numbers with decimals. Did you find a solution?
Hello @alfongon,
you would need to add a step
attribute to the form field. But, I can see that it’s currently not available from UI, so I’ve created an improvement task for this.
As a workaround, you can use the following filter, but you need to:
- Update the ID with your form ID (“hzfghd”)
- Update the field index (“field-1”)
add_filter(
'bricks/element/render_attributes', function ( $attributes, $key, $element ) {
// If it's not form element, return
// Update the ID with the Form ID
if ($element->element['id'] !== 'hzfghd' ) {
return $attributes;
}
// Add "step" attribute to the "field-1"
// Please note, that "field-1" is the index of the field in the form. Number "1" would indicate that this is the second element.
if (isset($attributes['field-1'])) {
$attributes['field-1']['step'] = '0.01';
}
return $attributes;
}, 10, 3
);
Hi guys,
We added this improvement in Bricks 2.0 RC, which is now available in your account.
Changelog: Bricks 2.0-rc Changelog – Bricks
Please let us know if you are still experiencing issues.
As with any pre-stable release, please do not use it on a production/live website. It is only meant for testing in a local or staging environment.