fix: single choice elements cannot be optionally required

This commit is contained in:
Adriano Caloiaro 2025-02-20 10:28:33 -07:00
parent ce05af1152
commit a10a52dcb7
No known key found for this signature in database
GPG key ID: C2BC56DE73CE3F75
3 changed files with 14 additions and 4 deletions

View file

@ -100,6 +100,16 @@ templ Head(pageTitle string) {
let watchingField = watchingFields[i]
let match = false
var watcherFieldElement = document.getElementById(watchingField.id) // the actual element watching the field
// radio form elements such as "single choice" elements cannot get gotten by ID because they are
// radio button in a form group, all sharing a "name" attribute, rather than having one unique id
// like other input elements. Thus, when we cannot get a watching field by ID, we must be able to get it by
// name.
if (watcherFieldElement == null) {
radioFormElements = document.getElementsByName(watchingField.id)
if (radioFormElements.length > 0) {
watcherFieldElement = radioFormElements[0]
}
}
var watcherFieldContainerID = `field-container-${watchingField.id}` // the DOM element that contains the watching field
logic = watchingField.logic

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 6 KiB