Post Field: 'Set as Parent' Does not save field value in Custom DB Table

Support MB Builder Post Field: 'Set as Parent' Does not save field value in Custom DB Table

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41801
    Ahmed E.Ahmed E.
    Participant

    Hi there,

    When I use a Post field and select the 'Set as Parent' option, the field value is not saved in the custom meta DB table.

    I know this is the expected behavior as stated in the DOCs, yet I think it is essential to add an option that allows saving the value as a meta value too besides setting it as the parent post.

    For example, many times I don't need the post data itself but just the metadata that is stored in a custom DB table. And in order to save/get the field value I would need to make an extra DB query!

    Is there a way to save the field value using filters without making an extra DB query?

    Also, please consider adding this option to the field asap.

    TIA.

    #41811
    PeterPeter
    Moderator

    Hello,

    If you use the option "Set as Parent", the field does not save the value to the postmeta table or custom table. It will set the post_parent in the table wp_posts. Saving a meta value, in this case, is not necessary.
    If you want to save a meta value to the DB, you can take a look at the action rwmb_after_save_post to set a post meta after saving the post.

    Please read more on the documentation
    https://docs.metabox.io/actions/rwmb-after-save-post/
    https://docs.metabox.io/extensions/mb-custom-table/#api

    #41813
    Ahmed E.Ahmed E.
    Participant

    Hi Peter,

    Thanks for your reply.

    Can you please consider adding this feature in future releases?

    Regarding saving it manually, is there a way to attach a field to rwmb_request()->set_post_data($_POST)?

    #41818
    PeterPeter
    Moderator

    Hello,

    I've created a feature request and our development team will consider supporting this feature in future updates.

    Regarding the saving field value manually, you can use the function rwmb_request()->set_post_data( $_POST ); with the hook rwmb_before_save_post or function update_post_meta() with the hook rwmb_after_save_post.
    Refer to the documentation
    https://docs.metabox.io/actions/rwmb-before-save-post/
    https://docs.metabox.io/actions/rwmb-after-save-post/

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