Fix step validation of number field

Will allow validation of number fields with step that's not an
integer. HTML5 fields allow steps to be float numbers.
pull/86/head
Oliver Tacke 2020-06-13 14:36:44 +02:00
parent 196888bf3e
commit 3b282f3903
1 changed files with 1 additions and 1 deletions

View File

@ -3754,7 +3754,7 @@ class H5PContentValidator {
// Check if number is within allowed bounds even if step value is set. // Check if number is within allowed bounds even if step value is set.
if (isset($semantics->step)) { if (isset($semantics->step)) {
$testNumber = $number - (isset($semantics->min) ? $semantics->min : 0); $testNumber = $number - (isset($semantics->min) ? $semantics->min : 0);
$rest = $testNumber % $semantics->step; $rest = fmod($testNumber, $semantics->step);
if ($rest !== 0) { if ($rest !== 0) {
$number -= $rest; $number -= $rest;
} }