Bug: Field of type “File” does not delete postmeta properly
-
Hello everyone,
the issue is reproducible when the user wants to remove the contents of a “file” field type and deletes the contents of the input element instead of clicking on the close button attached to the preview image.Expecting:
Both meta keys (‘my_field’ and ‘my_field_id’) for the file field should be removedWhat happens:
Only ‘my_field’ meta key is removed from the database while ‘my_field_id’ remainsHow to reproduce:
1. Create a new meta field of type file
2. Add an attachment
3. Save the post
4. Check database for ‘my_field’ and ‘my_field_id’ post meta
4. Delete the contents of the input field only
5. Save the post
6. Check database again, ‘my_field_id’ shall still be thereExample code:
$cmb = new_cmb2_box( [ 'id' => 'file_test_field', 'title' => "Test", 'object_types' => ['post'], ] ); $cmb->add_field( [ 'id' => 'my_field', 'name' => "Insert file here, then remove the input only and save the post", 'type' => 'file', ] );
- The topic ‘Bug: Field of type “File” does not delete postmeta properly’ is closed to new replies.