Bug - file_advanced field does not validate if file is removed via media library
Support › MB Conditional Logic › Bug - file_advanced field does not validate if file is removed via media library
- This topic has 1 reply, 2 voices, and was last updated 1 year, 11 months ago by
Peter.
-
AuthorPosts
-
May 23, 2023 at 8:33 PM #41897
JOANNA WHITTLE
ParticipantHi there,
discovered a minor bug involving the 'Conditional Logic' and 'Validation' which I hope you might fix for a future release.Steps to recreate:
1) Add the following custom fields:
add_filter( 'rwmb_meta_boxes', 'register_meta_boxes_details' ); function register_meta_boxes_details( $meta_boxes ) { $prefix = 'prefix_'; $meta_boxes[] = [ 'validation' => [ // RULES 'rules' => [ $prefix . 'file_download' => [ 'required' => '#prefix_download_visibility:checked', ], ], // MESSAGES 'messages' => [ $prefix . 'file_download' => [ 'required' => esc_html__( 'You must add/upload a PDF file when the download form is being shown!', 'text_domain' ), ], ], ], 'title' => esc_html__( 'Details', 'text_domain' ), 'post_types' => 'custom_post_type', 'id' => 'some_identifier', 'context' => 'normal', 'fields' => [ [ 'type' => 'switch', 'name' => esc_html__( 'Show Download', 'text_domain' ), 'id' => $prefix . 'download_visibility', 'desc' => esc_html__( 'Add downloadable content (EG: A Whitepaper).', 'text_domain' ), 'style' => 'square', 'on_label' => 'Show', 'off_label' => 'Hide', ], [ 'type' => 'file_advanced', 'name' => esc_html__( 'PDF Download', 'text_domain' ), 'desc' => esc_html__( 'Add a PDF file to be downloaded by the user.', 'text_domain' ), 'id' => $prefix . 'file_download', 'force_delete' => false, 'max_file_uploads' => 1, 'mime_type' => 'application/pdf', 'max_status' => true, 'visible' => ['prefix_download_visibility', 1], ], ], ]; return $meta_boxes; }
2) Toggle the 'Switch' to "Show" (In your custom post type). The file_advance field will be available.
3) Add/Upload a PDF file.
4) Publish/Update the post.
5) Delete the PDF you have just uploaded *IMPORTANT* via the "Media Library".
6) Return to the post (Where you originally uploaded the PDF file. Which will now be missing) and the toggle switch will still be on.
7) Click "Update" and the Validation no longer works to check if there is a PDF file attached to the 'file_advanced' field.* Removing the uploaded file (as in step 5 inline with the field within the post) does NOT create this problem.
Cheers 🙂
May 24, 2023 at 8:33 PM #41920Peter
ModeratorHello,
Thank you for your feedback.
I can reproduce the issue with the HTML validation
required
. I've escalated this issue to the development team to fix it in future updates. -
AuthorPosts
- You must be logged in to reply to this topic.