WIP: Conditions (UI) does not work on ACF repeater fields or sub fields

I cannot get conditions to work when targeting an ACF repeater field (row) or an ACF sub field.

Targeting the native WP custom field works, ala; {cf_sh_avstander} instead of {acf_sh_avstander}.

See attached image. For illustration purposes, I’ve set them both up, but only the top one actually works.

Hi Stein,
Thanks so much for your report!

Which version are you currently using? Please edit your report and add the version number.

However, I was able to reproduce the issue. Checking the ACF repeater values requires using the ACF have_rows() function, so comparing to empty, null or similar doesn’t work in this case.

Best regards,
timmse

3 Likes

Hey Stein,
Quick question: do you query the ACF repeater with a loop on the page? If not, you should try that. Then the conditions should work :v:

Hello timmse,

Thank you for looking into it.
I’m not sure I understand what you mean :no_mouth: Could you elaborate?

Stein

I thought we can check repeater field like that too, but apparently not:

1 Like

To be able to use the ACF repeater values, you must query them with a query loop, otherwise they are not available and therefore cannot be used in the conditions. This is our variant of the ACF have_rows() function.

So: Add an ACF Repeater query loop so that the entries are queried and accordingly available, and test the condition again.

Having this exact issue, any Bricks admins solution to this yet? I added a true/false tick box as a work around for now but not ideal

Hey guys,

I have run into this problem also and there doesn’t appear to be a native solution yet…?

@timmse I am querying my repeaters as loops in a template, but conditions still do not allow me to use any repeater sub-fields to check not-empty and conditionally display the parent block.

Does the process you’ve outlined only work on the specific block that the query loop is on?

I have my query loop block within a parent block that includes titling and context, which I expect is a common use-case for a repeater query loop. So of course, a user will want to conditionally show/hide the parent block in its entirety rather than just the rows of the repeater loop itself.

Is the BricksLabs solution linked above still the only way to achieve this? I’m keen to use Bricks native conditions as much as possible, and this seems like an oversight.

Cheers,
Tom

SOLUTION for me and maybe for others is already in Bricks :slight_smile:

I found this post outlining query_results_count that was apparently introduced in 1.9.1.

You can use this in your condition, along with the bricksID of the element that runs the loop looking for repeater rows, to do exactly what I was hoping to achieve in my previous post:

So thanks Bricks developers for already solving this use-case and hopefully this will help someone else who finds this post!

1 Like

Thanks for this solution @TomLD just search for a solution to this problem today.

1 Like