Theme code is wrong about a File Advanced field within a Group

Support Meta Box AIO Theme code is wrong about a File Advanced field within a GroupResolved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41674
    AdrienAdrien
    Participant

    Hello,

    I have a File Advanced (with max number of files 1) inside a MB group: https://markuphero.com/share/QoN2no3X7kS9neM30qge

    The code you provided (within Theme code metabox) is wrong: https://markuphero.com/share/NWU9Vr8ZZEjCb1ZJSgxi

    This is why I have a warning within PHP: "foreach() argument must be of type array|object, int given"

    Instead of the original code it should be: https://pastebin.com/P8bTRwxN

    EDIT: I think it's because initially the File Advanced field is supposed to have multiple files, that's why we have a foreach, but then why Meta Box is not returning an array of simply one item, if we have only one file within the File Advanced field?

    That's why Bricks have an error because they are waiting for an array when retrieve File Advanced Meta Box field.
    See my other thread on Bricks here: https://forum.bricksbuilder.io/t/meta-box-integration-fatal-error-with-file-advanced-field-within-a-mb-group/11945

    Thanks you 🙂

    Best regards,

    Adrien ROBERT.

    #41690
    PeterPeter
    Moderator

    Hello Adrien,

    I do not see the PHP error message on my local site. Please use the code below to print out the group value and share the value here. You can also export the field group to a JSON file and share it with me. I will take a look.

    echo "<pre>";
    print_r( $group );
    echo "</pre>";
    #41698
    AdrienAdrien
    Participant

    Hello Peter,

    It seems that the issue is from WS Form since I'm using it to upload the files.

    Message from Bricks team:
    "The root cause of your issue is the upload form.
    The form changed the way to store the file into non-array value.
    (And that's the reason why you use the official Metabox Theme code isn't work)

    [...]

    In this example, I uploaded the files via the wp backend, with no error and you can see the var_dump is standard like Metabox Theme code, the file Id stored in an array of the field name key.

    [...]

    This post uploaded files via the form, triggering the fatal error.

    "

    I'll ask them about it, thank you for your reply!

    #41699
    AdrienAdrien
    Participant

    You can delete this thread please @Peter, there is no problem whatsoever with Meta Box, you can delete it to clean up the forum from misunderstanding.

    Thanks!

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