Greetings,
I am trying to develop a select field which pre-populates with results from another field. I am generating sidebars with repeaters, and want to be able to select these sidebars on actual pages, so the sidebar slugs need to pre-populate the page fields.
I am using a configuration file, which I fear may be the issue as you can see below the configuration file is pre-populating with my development garage.
‘id’ => ‘acf_select-sidebar’,
‘title’ => ‘Select Sidebar’,
‘fields’ => array (
array (
‘key’ => ‘field_53d63fafa2145’,
‘label’ => ‘Select Sidebar’,
‘name’ => ‘select_sidebar’,
‘type’ => ‘select’,
‘choices’ => array (
‘karma’ => ‘Karma’,
‘asdf’ => ‘asdf’,
),
‘default_value’ => ”,
‘allow_null’ => 1,
‘multiple’ => 0,
),
),
Here’s the filter which I wish worked.
function act_load_sidebar_default( $field ) {
$field[‘choices’] = array();
// Get field from options page
if ( get_field( ‘sidebar_actual’, ‘option’, false ) ):
$row_count = 0;
while ( have_rows( ‘sidebar_actual’, ‘option’ ) ): the_row();
$label = get_sub_field(‘sidebar_title’);
$value = get_sub_field(‘sidebar_slug’);
//
$field[‘choices’][$value] = $label;
endwhile;
endif;
return $field;
}
add_filter(‘acf/load_field/name=field_53d63fe4f2ad9’, ‘act_load_sidebar_default’);
Any help would be greatly appreciated.