I played with the code for a bit longer and managed to get it working. Answer below
add_filter( 'gform_pre_render', 'freetrial_studios' );
add_filter( 'gform_pre_validation', 'freetrial_studios' );
add_filter( 'gform_pre_submission_filter', 'freetrial_studios' );
add_filter( 'gform_admin_pre_render', 'freetrial_studios' );
function freetrial_studios( $form ) {
foreach ( $form['fields'] as &$field ) {
if ( $field->type != 'select' || strpos( $field->cssClass, 'studio-list' ) === false ) {
continue;
}
$studio_id = $GLOBALS['post']->ID;
$studios = get_field('field_557a974776dd2', $studio_id);
if( $studios ) {
$choices = array();
foreach ( $studios as $studio ) {
// Populate the drop down field with values
$choices[] = array( 'text' => $studio->post_title, 'value' => $studio->post_title );
$field->choices = $choices;
}
$field->placeholder="Select a Studio";
$field->choices = $choices;
}
}
return $form;
}