Error with ajax file delete on CPT

Support General Error with ajax file delete on CPTResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33657
    sherwin_flightsherwin_flight
    Participant

    Hello,

    I'm using MetaBox as part of a premium theme.

    I have several custom post types where I use MetaBox, and all of them use "file" type fields. These fields include the ajax delete function to remove uploaded files. The way I have used these fields for each CPT is the same.

    On two of the CPTs the ajax file deletion works as expected. However, on one CPT I get an alert that pops up saying "Invalid File" when I try to delete files.

    I have done some initial troubleshooting, and see what the problem is, but I haven't tried to fix it yet.

    In the file inc/fields/file.php there is the following line:

    $field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );

    If I output the $field variable to a text file for debugging I can see the data on the two CPTs where ajax deletion works, but on the one CPT with the error the $field variable is blank.

    I had time to dig a little deeper, and in the code for the rwmb_get_field_settings function there is the following code:

    return rwmb_get_registry( 'field' )->get( $key, $type, $args['object_type'] );

    It is not returning anything for that one CPT.

    Any idea why this would work for two CPTs, but not the third?

    #33661
    sherwin_flightsherwin_flight
    Participant

    A little more info on this.

    In the rwmb_get_registry function, if I output the $data[ $type ] variable, the one CPT where the ajax file deleting doesn't work is missing from the data array. The other CPTs are listed.

    So the actual cause of my problem is that one of my CPTs is missing from the field registry.

    #33662
    sherwin_flightsherwin_flight
    Participant

    I have resolved this issue and you can delete this thread.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.