Optional radio buttons #44

davidsd opened this Issue Jul 20, 2012 · 2 comments


None yet

3 participants

davidsd commented Jul 20, 2012

It would be nice to be able to define a set of optional radio buttons, such that when the user is presented with a choice, none of the buttons are initially selected. Instead of a choice of type c, this would return a Maybe c, with Nothing representing the possibility that the user fails to select any of the radio buttons.

(Apologies if this is already possible -- after some wrangling, I've been unable to make it work. It appears that digestive-functors automatically chooses the first choice if the given default doesn't match any of the choices. For instance,

choice [(Just 1, "one"), (Just 2, "two")] Nothing

results in 1 being selected in the view.)


I am currently backpacking through Romania until the 30th of August, I'll
look at this when I get back.


For what it's worth, the common browser behavior that allows you to have an unselected radio element isn't part of the specification and there's no way to uncheck a radio once it's checked. I'd like to think that Digestive Functors is following with the spirit of the specification in this particular case (especially when you consider that select and radio are interchangeable in behavior, and you most certainly cannot have a select element with no default value).


Radio buttons are like checkboxes except that when several share the same control name, they are mutually exclusive: when one is switched "on", all others with the same name are switched "off". The INPUT element is used to create a radio button control.

If no radio button in a set sharing the same control name is initially "on", user agent behavior for choosing which control is initially "on" is undefined. Note. Since existing implementations handle this case differently, the current specification differs from RFC 1866 ([RFC1866] section, which states:

At all times, exactly one of the radio buttons in a set is checked. If none of the elements of a set of radio buttons specifies `CHECKED', then the user agent must check the first radio button of the set initially.

Since user agent behavior differs, authors should ensure that in each set of radio buttons that one is initially "on".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment