ACF 将数据库中的选择填充到后端的选择框中

ACF populate choises from database into the choices box in the backend

我怎样才能从数据库中而不是静态地填充选项?见附件:

我把这个功能加入了我的 function.php,所以我只需要在自定义 table 中添加我的选项,例如国家。

function makeChoiceArrayForACF($postid){
    $datafromdbase = someFunctionToGetDataFromDbase();
    $newdbasearray = array();
    foreach ($datafromdbase as $key => $value){
        $newdbasearray[$key] = $key;
    }
    $new = array(
        'multiple' => 0,
        'allow_null' => 1,
        'choices' =>
            $newdbasearray,
        'default_value' =>
            array(),
        'ui' => 0,
        'ajax' => 0,
        'placeholder' => '',
        'return_format' => 'array',
        'type' => 'select',
        'instructions' => '',
        'required' => 1,
        'conditional_logic' => 0,
        'wrapper' =>
            array(
                'width' => '',
                'class' => '',
                'id' => '',
            ),
    );
    $my_post = array(
        'ID'           => $postid,
        'post_content' => serialize($new),
    );
    wp_update_post( $my_post );
}

add_action('init', 'admin_only');

function admin_only() {
    if( !is_admin() )
        return;
    makeChoiceArrayForACF(16611);
}