Home Forums Backend Issues (wp-admin) Select field on attachment not populated by acf/load-field


Select field on attachment not populated by acf/load-field

  • I have some select field when uploading attachments, the fields appear but they are not being populated by another field.

    they work if they are on a page edit (for example).

    and work if i manually create the fields array. Is somehow the get_field not loaded when managing the attachments?

    add_filter('acf/load_field/key=field_5afbf7bb8380b', function( $field ){ 
        $field['choices'] = array();
              //this works outside of the attachement
    		$bundles = get_field('gerir_portfolio_modelos', $pageidselects );
        foreach( $bundles as $bundle ){
          $val =  str_replace(' ', '+', $bundle['listamodelos']);
    			$name = $bundle['listamodelos'];
          $field['choices'][$val] = $name;
    //if i load them from here directly they work, if not its empty.
         $field['choices'] = array('teste' => 'working', 'teste2' => 'weee');
        return $field;
    } );
  • I’ve tried to load the array outside of the acf_load and pass it inside and it works.

    $teste =get_field('gerir_portfolio_modelos', $pageidselects );
    add_filter('acf/load_field/key=field_5afbf7bb8380b', function( $field ){ 
    	global $teste;
             foreach( $teste as $bundle ){ (...)

    and it works as expected.

    well this fixed it, but i would like to understand why did this happens,

    Is this a know bug, or am i missing something?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Select field on attachment not populated by acf/load-field’ is closed to new replies.