Add gravityforms
as field’s Wrapper Attributes class.
// Dynamically populate the options of an ACF select field with Gravity Forms existing on the site
if ( class_exists( 'GFForms' ) ) {
add_filter( 'acf/load_field/type=select', function( $field ) {
if ( 'gravityforms' == $field['wrapper']['class'] ) {
$gf['forms']['active'] = GFAPI::get_forms();
$gf['forms']['inactive'] = GFAPI::get_forms( false );
$gf['forms']['all'] = array_merge( $gf['forms']['active'], $gf['forms']['inactive'] );
foreach ( $gf['forms']['all'] as $form ) {
$field['choices'][ $form['id'] ] = $form['title'];
}
}
return $field;
} );
}