black friday sale

Custom Fields
Re-Envisioned
Support MB Custom Table Bug (maybe) MB Custom Table with Select Advanced field

  • Creator
    Topic
  • #22870
    Resolved Trang Nguyen
    Participant

    Hi!
    Maybe there is a bug when using MB Custom Table with Select Advanced fields (multiple).

    When I write
    $values = rwmb_meta( $field_id );
    echo count($values);

    It always shows 1 unit more than the actual result.

    For example:
    I have 2 select advanced fields (multiple) A and B.
    – A saves data in postmeta
    – B saves data in a custom table.

    I choose 2 items for each field when writing post.
    With similar echo count($values) code, I get:
    – A: 2 (correct)
    – B: 3 (incorrect, there are only 2 items)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #22871
    Trang Nguyen
    Participant

    Hi!
    There is another similar issue with Custom Table and Post field with multiple choices:

    If a post field saves data to a custom table, it also saves ‘i:0;s:0:””‘ before other items.
    I choose 2 posts and this is the data I have in the database
    a:3:{i:0;s:0:"";i:1;i:194;i:2;i:197;}

    Because of this, when I use this code

    $post_ids = rwmb_meta( $field_id, ['storage_type' => 'custom_table', 'table' => $table_name] );
    foreach ( $post_ids as $post_id ) {
        echo '<p>', get_the_title( $post_id ), '</p>';
    }

    It shows as I have 3 posts, not 2.

    #22875
    Long Nguyen
    Moderator

    Hi,

    I’m going to check it out and let you know later.

    Thank you.

    #23388
    Long Nguyen
    Moderator

    This issue has been fixed in the new version of MB Custom Table v1.1.11. I’m going to mark this topic as Resolved.

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