dokuwiki
dokuwiki copied to clipboard
checkboxes/radiobutton are not correctly prefilled
If you use one checkbox, and it was first checked, but later unchecked. Then on a page reload (e.g. preview), it is not detected that the checkbox was unchecked. It stays checked, because if it is unchecked, it is not submmitted, and the INPUT->has() (line 35) is of course negative, such that the actual check is not reached.
I can image this would work better i the situation with more checkboxes with the same name (array), but if everything is unchecked the same issue happens. (Radiobutton not tested, but I guess it has the same issue. Because it will also not submit a value if no option is selected. However, one out the given radiobutton can be max selected, which can be not unselected without selecting another option. I guess most forms will set already a default choice.)
The prefill function: https://github.com/splitbrain/dokuwiki/blob/3578bf969ba82be3add2b1a26ff544163a68aa7e/inc/Form/CheckableElement.php#L26-L63
On a fresh page load it is never set. If you have a reload of the form due to preview/error displaying, then it has a meaning that the checkbox not set (i.e. has()=false=unchecked).
So such a check can only work if we can recognize this form is submitted. Is that possible to recognize with only this field, or should we use other fields/button for that.
Somewhere an extra hidden field with same name was mentioned as option for a false value. This works. Is this desired to include in the html generation?