I believe this issue was introduced by this issue: https://www.drupal.org/node/2857854
And this commit: https://cgit.drupalcode.org/webform/commit/?h=7.x-4.x&id=be55cd4d6209d49...

The specific code affecting my immediate problem is from number.inc line 659:

// Integer test.
if ($element['#integer'] && filter_var((float) $numeric_value, FILTER_VALIDATE_INT) === FALSE) {
  form_error($element, t('!name field value of @value must be an integer.', array('!name' => $element['#title'], '@value' => $value)));
}

It appears to me that $numberic_value is cast to (float) and then validated as an int which will always === FALSE.
That makes the conditional TRUE, and we will always get a form error.

As a result, we can not submit a form that includes a number field that requires an integer.

$numeric_value is "standardized" and verified as numeric further up the parent conditional (lines 634, 635), so I feel like casting this as a float is unnecessary, even given the arguments in the previous issue for the other instances of this change.

I will attach a patch removing the cast to float on 659 in order to solve our use case, and will circle back to review the other cases if discussion here warrants it.

Comments

sleepingmonk created an issue. See original summary.

sleepingmonk’s picture

StatusFileSize
new616 bytes
sleepingmonk’s picture

Further testing show that this may not be an issue for small integers, however in my case, any values over 14 digits are failing. Removing the cast to (float), still solves the problem, but I'm not as clear why now.

liam morland’s picture

Title: Integer test will always be invalid. » Integer test will always be invalid

Thanks for the patch. Please update the tests to cover this problem. Remember that there are PHP limits on integer size. Floats can be bigger.

jenlampton’s picture

Status: Active » Reviewed & tested by the community

I'm running into the same problem, patch also fixes the issue for me.

jenlampton’s picture

Title: Integer test will always be invalid » Large Integers will fail integer validation test

Also updating issue title.

jenlampton’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new817 bytes

In further testing, I found that the attached patch will fail on integers with leading zeros like 01. I'm attaching a new patch with seems to solve both problems of leading zeros and very large integers in my environments.

Status: Needs review » Needs work

The last submitted patch, 7: webform-integer_validation-2984499-7.patch, failed testing. View results

liam morland’s picture

Status: Needs work » Closed (outdated)

Drupal 7 is no longer supported. If this applies to a supported version, please re-open.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.