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
Thanks for letting us know about this bug.
Passing it to the developer so that he can look into the issue.
Thanks for the topic.
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?
Thanks
E
Hi Elliot,
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? 🙂
Cheers
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.
Cheers
E
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
Helping others is a great way to earn karma, gain badges and help ACF development!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?
— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.