UI: Numeric Input with stepsize
Currently, the UI Framework lacks an input for floats. HTML5 specifies the step-attribute for numeric inputs: https://html.spec.whatwg.org/multipage/input.html#attr-input-step
We propose "withStepSize" for \ILIAS\UI\Component\Input\Field\Numeric as described below. This limits the steps to numerics without the "any" option and lets us predict the expected value as int or float.
Consequently, when the step size is given as a floating point number, the field's value will be a float, too, even if it's a whole number. When the stepsize is omited or given as int, decimals will not be allowed or possible.
This will not have any impact on existing code, but will enhance the possibilities of numeric input. A close-by usecase is the scoring of test questions, where points are given as floats.
Hi @nhaagen,
could we just prepend the transformation to the existing one when setting the property to solve the problem that a transformation that was already attached would become invalid?
Kind regards!
Hi @thibsy, hi @Amstutz,
please have a look into this. Please note, that this change will switch types of the contained value, which I opposed in some other case (can't seem to recall which, though). I think it is ok here, because alternatives seems to be worse: For one, I think that everyone using floats invites the devil to her code anyway, so this won't make it worse. On the other hand, creating a dedicated numeric input with fixed point content would make it even more probable that someone actually uses the field. Finally, this only exists because we need it for some case that strongly makes the point that floats are bad (something something points in the T&A), so why bother fixing.
Hope this makes some sense.
Kind regards!
Jour Fixe, 04 AUG 2025: We highly appreciate this suggestion to support the input of floats and accept the PR for trunk.