Force cleanup of setting value type "checkboxes" when is empty #20600
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
When using a custom setting of type
checkboxes
, if there's no checked value in the group, it's not saved empty in the DBBefore
Add a custom setting type
checkboxes
in you extension with multiple options, go to to Generic Admin Form, and save any value. Then go back and uncheck all the boxes, the empty value is not saved in the DB, previous value remains.After
Empty value is saved in the DB; if there's no box checked in the Generic Admin Form
Technical Details
Looks like the setting type
checkboxes
is not fully supported in Civi yet, (as a singlecheckbox
), probably more PRs coming after this one to add more features to this useful setting typeComments
I haven't found many implementations of custom settings of type
checkboxes
in the community, but it's fully documented as part of settings MetaData in docs, but still needs some love in the source code to fully work as expected.