Support

Account

Home Forums Backend Issues (wp-admin) Make Post Object Field Searchable by Dynamically Populating Hidden Text Field Reply To: Make Post Object Field Searchable by Dynamically Populating Hidden Text Field

  • Hello –
    I have made a little bit of progress on this post. I have been able to get the first of the repeater rows to show the list of names in the searchables field. Any idea why the second repeater row is not adding to the list of names?

    function my_acf_load_value($value, $post_id, $field) {
    	if( have_rows('employee_group') ):
    		while ( have_rows('employee_group') ) : the_row();
    				global $post;
    				$post_objects = get_sub_field('group_members');
    				if( $post_objects ):
    					foreach( $post_objects as $post):
    					setup_postdata($post);
    					
    							$id = get_the_ID();
    							$first = get_field('first_name', $id);
    							$last = get_field('last_name', $id);
    							$name = $first . ' ' . $last . ', ';
    							$names .= $name;
    					endforeach;
    					wp_reset_postdata();
    				endif;
    	endwhile;
    	  $value = $names;
    	else :
    		// no rows found
    	endif; wp_reset_postdata();
    	return $value;
    }
    add_filter('acf/update_value/name=searchables', 'my_acf_load_value', 10, 3);

    Thanks for taking a look at this. Any help is greatly appreciated.

    Ben