when migrating to acf pro 5.2.4 the fields of type boolean that are required will not accept in the edit form the checkbox unchecked (value = false) display an error message saying ‘field is required’. Before 5.2.4 this was working fine
Yes, this is a new validation rule that I have added in to 5.2.4
If a checkbox is required, then it’s value must be ticket.
Similar to when checking out on an online store and the ‘Term and Conditions’ checkbox is required.
Do you think there is an error in the validation logic?
yes but this is logically incorrect: if I have a boolean field, the possible values are TRUE and FALSE.
So once the user is prompted to fill a form, a checkbox unticket is representing a FALSE value, so it’s NOT empty.
Imagine the case where a field is ‘Do you want a newsletter?’ so it means that the checkbox must be checked always? 🙂
PS: peraphs I tried to unset the required attribute (to let my form works) but due to a bug on 5.2.4 (not ablet to save/update large field group) I reverted back to 5.2.3 (I see today a 5.2.5 version is available that fix this bug).
Thanks mate. I’ll get a few other opinions on this before considering changing back the required validation.
I still think a required checkbox should contain a value. “” or unselected or unchecked is considered as not a value (text field, select field, etc), so this would be consistent with the new validation logic.
I highly encourage you to upgrade to 5.2.5 and make your checkbox un-required.
Looking forward to hearing back about this from other users.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users