Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291717

Cannot submit form containing decimal (20/10) field with manual value

$
0
0

Problem/Motivation

When having a a Number (decimal) with precision of 20 and scale of 10 it's impossible to submit manually entered values like 1.0 100.0 aka >= 1

It seems impossible to enter values greater equal 1.

Probably core/lib/Drupal/Component/Utility/Number.php:37 is in error?

<?php
  public static function validStep($value, $step, $offset = 0.0) {
    $double_value = (double) abs($value - $offset);
?>

From #4

It seems to me that validStep shouldn't be called for a decimal number as it's not supposed to be a IEEE 754 single or double precision float and that function validates for that.

If the precision/scale is set to 20/10 then the precision is higher than a double for most values and the validation fails.

I've changed the test for that in my patch.

Steps taken

  1. Add a Number (decimal) to http://drupal.d8/admin/structure/types/manage/article
  2. Set precision to 20
  3. Set scale to 10
  4. Add/edit an article
  5. Click the number spinner and save the node: Ok
  6. Type 1.001 and save the node: Decimal is not a valid number.
  7. Use the spinner (value is now 1.0000100001) and save the node: Decimal is not a valid number.
  8. Change value to 0.0000100001 and save the node: Ok

Proposed resolution

Detach decimal field from the number validation. It's not a float and has no scale. It's validation can be done exactly by ie a regex.

Remaining tasks

User interface changes

API changes


Viewing all articles
Browse latest Browse all 291717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>