Afform - Custom fields of type YesNo (boolean): Defaults not displayed and changes not saved
To reproduce set up a simple submission form:
- Add Individual
- Add "is_deceased" field (a Yes / No radio field) (optional)
- Add a contact custom field of type "YesNo" (optional)
Create a contact and set the contact is_deceased = true and custom field "YesNo" = true
Load the form with URL parameter eg. #?Individual1=169 to load that contact
See that is_deceased field is set to Yes but the customfield is not set.
Now set the customfield to "No" and submit the form. Reload the form and see that it did not save the value of the custom field :-(
So two issues:
- Custom field value is not displayed: It is retrieved via prefill as a bool but the field is added with radios that have values 0,1.
- Custom field value is not saved: It is converted to int (0 or 1) once submitted whether submitted as "false" or 0.
I've been round and round trying to work out how this should be fixed but have hit a dead end!
The display issue can be "fixed" by either not passing the options to the form or by passing them with true/false instead of 0,1. But the value still doesn't save.
@colemanw Any ideas?