Home › Forums › Front-end Issues › Javascript API: Set data-conditions manually? › Reply To: Javascript API: Set data-conditions manually?
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.
You could probably also do this using JavaScript by accessing the data value of the field. The value looks like a json encoded array. However I do not know if this will work, I don’t know it this need to be there before ACF initializes or not or if there is a way to reinitialize it if it does not.
$('[data-key="YOUR FIELD KEY"]').data('conditions', 'JSON ENCODED ARRAY');
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.