+1 for this option
Really, the “button” is just a styling. This should be a presentation option within the checkbox and radio fields instead of a separate element. This is born out in the generated code for Button Group “fields”.
This is working well for me, with the option to make the loaded fields editable or not:
/* Default ACF fields */
function my_default_acf_fields() {
if ( ! acf_get_field_groups() ) {
$acf_json_data = @file_get_contents ( MY_PLUGIN_DIR . 'vendor/acf-json/my-acf-groups.json' );
if ( $acf_json_data && $custom_fields = json_decode( $acf_json_data, true ) ) {
foreach ( $custom_fields as $custom_field ) {
acf_import_field_group( $custom_field ); // editable
// acf_add_local_field_group( $custom_field ); // not editable
}
}
}
}
add_action( 'acf/init', 'my_default_acf_fields' );
This is the code I ended up with to handle the cloned repeater:
function my_acf_sections( $area = '' ) {
if( ! function_exists( 'get_field' ) ) return;
$page_id = get_queried_object_id();
if( have_rows( $area, $page_id ) ) :
while( have_rows( $area, $page_id ) ) : the_row();
$section_content = get_sub_field( 'section_content' );
if( $section_content ) {
// Do stuff with fields
} else {
// Handle cloned repeater
$clone = get_field_object( $area );
if( ! isset( $clone['sub_fields'] ) ) continue;
$clone = get_field_object( $area )['sub_fields'][0];
if( $clone['_clone'] ) my_acf_sections( $clone['name'] );
}
endwhile;
endif;
}
I’m open to suggestions for something better.
Same problem 5.3.1 to 5.3.2.1