Support

Account

Home Forums ACF PRO Post object selects are empty Reply To: Post object selects are empty

  • Okay, I understand a tad better how all of this is running, but still, I haven’t solved my issue.

    According to what you said, I dug my way from the called AJAX (with action: acf/post/get_field_groups) but again, I’m stuck in the function acf_get_value() in file “api-value.php”, where, I understand, the value are fetched for filling the field.

    Several filters are applied but none return anything :

    $value = acf_get_metadata( $post_id, $field['name'] );
    ...
    $value = apply_filters( "acf/load_value", $value, $post_id, $field );
    $value = apply_filters( "acf/load_value/type={$field['type']}", $value, $post_id, $field );
    $value = apply_filters( "acf/load_value/name={$field['_name']}", $value, $post_id, $field );
    $value = apply_filters( "acf/load_value/key={$field['key']}", $value, $post_id, $field );

    (This is for a new post, for an older post, acf_get_metadata returns the values for the field already associated with the post)

    I printed the output of each call, but they all come back empty.

    Furthermore, the load_value() function from “class-acf-field-post_object.php” looks like this :

    function load_value( $value, $post_id, $field ) {
    	// ACF4 null
    	if( $value === 'null' ) return false;
    		// return
    		return $value;
    		
    }

    This function doesn’t look really useful to me… I checked on other class files, “class-acf-field-select.php” has the same function, but other files (ex “class-acf-field-taxonomy.php”) have real code for this function, so, even if I updated the plugin yesterday, I wondered if some files have been altered and not updated, or if these function are the real ones.

    I also checked about select2, since you mentionned it, I found a get_ajax_query() function in “class-acf-field-post_object.php” (“This function will return an array of data formatted for use in a select2 AJAX response”) which seems to do what I want, but I put some tracker in it, and it doesn’t seem to be called, so maybe the problem is this function should be the one called, but because of some bug, it isn’t and another one is instead ?