An issue with the `file_upload` field when it's required

Support Meta Box AIO An issue with the `file_upload` field when it's requiredResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #37240
    Alaan TVAlaan TV
    Participant

    I have a settings page with some custom fields, one of them is a file_upload field which is defined like this:

    [
        'name'              => 'Video file',
        'id'                => 'video_file',
        'type'              => 'file_upload',
        'required'          => true,
        'max_file_uploads'  => 1,
        'max_status'        => false,
        'attributes'        => [
            'accept'   => 'video/*',
            'onchange' => 'video_preview_update_src(this.files[0])',
        ],
    ],
    

    Whenever I submit the settings page, I get an error that This field is required. even when the file is already selected and uploaded. And the accept attribute is not working which should filter the selected files to accept video files only.

    But this snippet of code works perfectly when I set the type of the custom field to file, not file_upload.

    I noticed that once the file is selected and uploaded, the value attribute of the <input> tag is not updated, and that's why it considers the field empty.

    And to make the accept attribute work with the file_upload field, it should be added to the Select Files button <input> tag (the second marked one in the screenshot).

    #37241
    Alaan TVAlaan TV
    Participant

    Just another note, we upload videos to the cloud (Amazon S3), and that takes time to get the attachment ID that should be stored in the value attribute. Once we select the video file, the value attribute is added to the <input> tag with no value, but after the video is fully uploaded and the attachment post is created, the value attribute is not getting updated.

    #37269
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    I also experience that issue on my demo site. I've escalated the issue to the development team to fix it in the next update.

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