Optional list rendered with radio button

Just wondering why the radio rendering of a list type is always required:


<input type="radio" name="#arguments.fieldname#" class="required #arguments.stMetadata.ftClass#" value="#optionValue#"<cfif listFindNoCase(arguments.stMetadata.value, optionValue)> checked="checked"</cfif> />

I’m aiming for an optional Yes/No field - i.e. we want to know if they’ve answered yes, no or not at all.

Would the fix be to include this:

<cfif structKeyExists(arguments.stMetadata, "ftValidation") AND listFindNoCase(arguments.stMetadata.ftValidation, "required") >
    <cfset arguments.stMetadata.ftClass = ListPrepend("required", arguments.stMetadata.ftClass, " ") >

and then just use arguments.stMetadata.ftClass as the class?


Seems reasonable to have a radio group that doesn’t require a selected item. If you fix the default selection in the UI, then no selection should simply not pass any form value for that property.

On the other hand, you could have three radio buttons; “not at all”, yes and no. Defaulting to “not at all” and recording a suitable value might be a workaround.