Home › Forums › General Issues › Logic between number and relationship fields › Reply To: Logic between number and relationship fields
I was able to do it in a static way using some code from another thread here
My current code looks like this
function load_proper_choices_number ( $field ) {
global $post;
if (!$post ||
!isset($post->ID) ||
( get_post_type($post->ID) != 'featured-content' ) ) {
return $field;
}
$number_value = get_post_meta($post->ID, 'featured_posts_number');
$field['max'] = $number_value;
return $field;
}
add_action( 'acf/load_field/name=featured_posts', 'load_proper_choices_number');
Works properly with a refresh every time I change the number of posts using the Number field, and now I will try to achieve it using some javascript. I do assume updating the data-max attributes of the relationship field should do the job.
Will let you know.
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.