Home › Forums › Bug Reports › Block validation bug with nested groups and conditional logic
Hello,
I would like to report a bug we ecountered this week. Since the 6.3.1 release, required fields that need a conditional logic are not being validated properly if this field is inside a group that is inside another group, example:
If I add those fields to a block, and the true/false is set to false, meaning that the required field will not be displayed, the validation works fine and I can proceed to save the page, but if I load the page again, to edit for example, it will automatically throw a validation error, and I cannot save the page again, that’s because the required field that is displayed on the true condition is empty, but it should not be validating this field because the condition is set to false and the field should not be displayed.
If this was brought up already before you can ignore the topic and link me to the main issue please.
Same issue is occurring with block fields. On initial edit screen load the block shows as Validation Failed. Changing any value of any field in the block will clear the error.
The setup for the block in question is using 3 fields where 2 of them are conditionally displayed based on the third field.
Structure:
Content type (select field): Image or Video
Image File (image field, conditional based on Content type being Image)
Video URL (text field, conditional based on Content type being Video)
Hey folks,
Could you all please contact [email protected] so we can run through some debugging and get copies of your field groups etc?
We’ve not have a reliably reproducible case of this bug yet, so you can help us get to the bottom of it and we’ll sort out a patch in an upcoming release.
Thanks,
Liam
Not sure if this is already fixed in an upcoming release, but I’d like to add my two cents.
Best way that I have found to replicate this is to make a repeater-field with two required text fields and a true/false which is used for conditional logic.
Set one textfield to show when the true/false is unchecked and hide the other. viceversa for when the true/false is checked.
IE;
Textfield A*: show if value is equal to unchecked.
Textfield B*: show if value is equal to checked.
If you then reload the edit page it wil invalidate the block and prevent the entire page from being updated. When you nibble on the true/false checkbox (or kick any field in the repeater) it will update and presumably see the conditional logic and validate the field again, allowing you to update the page.
Although, it doesn’t seem to be limited to just repeaters, as similar logic in the block itself has problems too.
This is in combination with ACF’s Gutenberg block functionality by the way.
I would like to +1 @kevinspanish comment. Having a required field that is hidden by conditional logic seems to create that bug. As mentioned the error only occurs when the edit page is reloaded.
Seems to be introduced in version 6.3.1, as version 6.3.0.1 is working as expected without the validation errors.
So just going back a few versions is the best fix for now.
@kevinspanish according to the changelog the issue should be fixed with version 6.3.5.
Didn’t have the chance to test it yet.
https://www.advancedcustomfields.com/changelog/
Greetings, Adam
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.