I wonder whether this is possible, as I couldn’t find any documentation on it: I’d like to manually set the
I assume I’d have to call some kind of registration function so that the ACF script is aware of this condition as I’d probably set the condition attribute on document.ready.
The reason I want to do this is that I’d like to use the available functionality to show/hide fields for a is in a different field group than the conditional field it is supposed to depend on.
You can do this using an acf/load_field or an acf/prepare_field filter. In either of these functions you can set the conditional logic and base it on any field using the field’s key.
$('[data-key="YOUR FIELD KEY"]').data('conditions', 'JSON ENCODED ARRAY');
Sounds like a great idea using the PHP filters. I’ll check for the correct implementation and post the code.
For the JS solution, I tried adding a condition from the browser inspector which doesn’t seem to work. So, I assume this needs to happen before the initialization.
Basically, what I do is I create a field group with a similar set of fields and use the export to PHP to see how the conditional logic should look. Then you just have to replace the field key with the key of the field you actually want to use. This can’t be done when building a field, but like I said, any field that exists on the same page will do the trick, even if it is in a different group. Or it did the last time I tried it.