Skip to content
This repository was archived by the owner on Dec 20, 2025. It is now read-only.
This repository was archived by the owner on Dec 20, 2025. It is now read-only.

Radio button true and false value bug #68

@andrewchernow

Description

@andrewchernow

When a group of radios uses "true" or "false" for their values, form2js converts these to boolean true and false. However, if you add a 3rd radio to the group to indicate "none selected" or "no answer" or "any" and set its value to "", form2js will convert the checked radio with a value of "" to boolean false. However, if you don't use "true" and "false" as the values, the "" value works as expected.

This is because of the radio case in getFieldValue, which falls-through to the checkbox case. The offending line from the checkbox case is:

if(!fieldNode.checked && fieldNode.value === "true") return false;

This is correct for checkboxes, but for something like:

any
on
off

It is broken. I should not get back boolean false if the "any" radio is checked. I should get back "". To fix this, i just copied the statements from the checkbox case in getFieldValue, excluding the offending line, to the radio case.

Point is, this feels like a bug or maybe just unexpected behavior. IMHO, getFieldValue should not treat a radio just like a checkbox.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions