-
Task
-
Resolution: Unresolved
-
Minor
-
None
-
3.11.5, 4.0
-
None
-
MOODLE_311_STABLE, MOODLE_400_STABLE
This was detected while working on MDL-73824 and moving some forms (category_form.php, item_form.php) elements from RAW to the "float" type.
When information arrives to the the validation() method of the form, we can find these values:
- If the field is disabled then the information arrives as string, with the raw value in the form (for example 50,00, given I'm using comma decimal separator).
- If the field is enabled, then it arrives as:
- unformatted float if it's correct (50.00)
- boolean false if it incorrect
- empty string if it's empty.
- If the field is frozen.... haven't tested!
It makes a little bit tricky to perform extra validations in the method, because somehow the values are not consistent, specially between #1 and #2.1 , and that makes things non-predictable.
So this issue is about to:
- See if it's possible to be more consistent (#1, #2.1, #3 specially) about the values processed, so they are always unformatted floats when possible.
- Cover all cases with some tests
- Review current 'float' uses in core, there aren't many, specially if the have some custom validation() or other functions that are not receiving the $data consistently. Specifically, but not only, review these two, because they were "fixed" in
MDL-73824andMDL-74516to workaround the problem. They have a TODO comment pointing to this issue (search by 'MDL-73994' in core):- grade/edit/tree/category_form.php
- grade/edit/tree/item_form.php
- course/moodleform_mod.php
- mod/workshop/mod_form.php