I am new to Groovy and trying to work with checkboxes. It is still checked even though completed is false.
tr {
td("Completed")
td(":")
td {
input(name: 'completed', type: 'checkbox', checked: todo.completed, value: todo.completed)
}
td(todo.completed)
}
Any help will be much appreciated.
Cheers.
CodePudding user response:
This'll satisfy the immediate need:
if (todo.completed) {
input(name: 'completed', type: 'checkbox', checked: selected, value: todo.completed ?: false)
} else {
input(name: 'completed', type: 'checkbox', value: todo.completed ?: false)
}
It's ugly, but it works.
The key takeaway is the absence/presence of the "checked" attribute, as pointed out by u/shivasprogeny.
I'm curious enough to continue to pound against this and perhaps find a better answer.