Support

Account

Home Forums Backend Issues (wp-admin) Select2 not working Reply To: Select2 not working

  • Here is the whole code:

    // Change Field into a select
    $field['type'] = 'select';
    $field['ui'] = 1;
    $field['ajax'] = 1;
    $field['choices'] = array();
    
    // get sites
    $sites = $this->acf_get_sites();
    
    // set choices
    if( !empty($sites) ) {
    
    	foreach( $sites as $site ) {
    		
    		//get blog name
    		$current_blog_details = get_blog_details( array( 'blog_id' => $site['blog_id'] ) );
    		
    		// append to choices
    		$field['choices'][ $site["blog_id"] ] = $current_blog_details->blogname;
    
    	}
    
    }
    
    // render
    acf_render_field( $field );

    Its almost the same like the post_object. I have no JS errors. Without ui and ajax its just fine.