Skip to content

Commit 9a4046d

Browse files
Tim Berners-LeeArne Hassel
authored andcommitted
Do not prefill a value for a checkbox
If the BooleanField in the given resource is not set, the tristate logic would set it to false by default. This commit changes that to differentiate between the value that is shown (false), and the value that's actually present on the web.
1 parent 110c54d commit 9a4046d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/widgets/forms.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,20 +1202,22 @@ function buildCheckboxForm (dom, kb, lab, del, ins, form, store, tristate) { //
12021202
}
12031203
function refresh () {
12041204
var state = holdsAll(ins)
1205+
var displayState = state
12051206
if (del.length) {
12061207
var negation = holdsAll(del)
12071208
if (state && negation) {
1208-
box.appendChild(error.errorMessageBlock(dom,
1209+
box.appendChild(UI.widgets.errorMessageBlock(dom,
12091210
'Inconsistent data in store!\n' + ins + ' and\n' + del))
12101211
return box
12111212
}
12121213
if (!state && !negation) {
1214+
state = null
12131215
let defa = kb.any(form, UI.ns.ui('default'))
1214-
state = defa ? defa.value === '1' : tristate ? null : false
1216+
displayState = defa ? defa.value === '1' : tristate ? null : false
12151217
}
12161218
}
12171219
input.state = state
1218-
input.textContent = {true: checkMarkCharacter, false: cancelCharacter, null: dashCharacter}[input.state]
1220+
input.textContent = {true: checkMarkCharacter, false: cancelCharacter, null: dashCharacter}[displayState]
12191221
}
12201222

12211223
refresh()

0 commit comments

Comments
 (0)