I’m using the following code to populate choices for a subfield in based on values of two other fields (I need to allow the editor to type in the fields person_1 and person_2 then use those two values as the choices in a subfield for the same post.) This works to populate those choices, but only if you add the two values, then save before you move onto the subfield. Is there a way to dynamically add the choices from other fields without having to save the post first? Thanks!
// Load Chat / Interview Names to field
function RS_acf_load_field( $field )
// reset choices
$field['choices'] = array();
// get the choice values from other fields
$choice1 = get_field('person_1');
$choice2 = get_field('person_2');
$choices = "$choice1;$choice2";
// explode the value so that each line is a new array piece
$choices = explode(";", $choices);
// loop through array and add to field 'choices'
if( is_array($choices) )
foreach( $choices as $choice )
$field['choices'][ $choice ] = $choice;
// Important: return the field
Thanks for the lead, Elliot! I have to believe that someone else has run across this and come up with a solution… Any way I could get some direction on what script to use in the function? Thanks so much for your help!