It's possible to save custom fields only to custom table bypassing wp_posts?
Support › MB Custom Table › It's possible to save custom fields only to custom table bypassing wp_posts?Resolved
- This topic has 6 replies, 2 voices, and was last updated 1 year ago by
Aishwarya.
-
AuthorPosts
-
March 19, 2024 at 3:21 PM #44907
Aishwarya
ParticipantI am creating custom fields only using PHP code.
I creating a form to get entries for income/expense as part of the project and this doesn't have any relationship with
wp_posts
andwp_post_meta
.I referred to this support threads https://support.metabox.io/topic/store-mb-settings-not-to-posts/?swcfpc=1
https://docs.metabox.io/extensions/mb-custom-table/#creating-a-custom-tableI don't want to create a post in wp_posts table for each entries as it doesn't required. It is possible to bypass storing the custom field values to wp_posts and just save to the custom table using
'storage_type' => 'custom_table', // Must be 'custom_table' 'table' => 'transactions',
Let me put it straight: I simply want to utilize the Metabox fields to display on the frontend submission using a shortcode, without being tied to any 'post_type,' and save them to a custom table.
March 19, 2024 at 4:18 PM #44908Aishwarya
ParticipantSorry, I missed this part in the documentation https://docs.metabox.io/extensions/mb-custom-table/#custom-models I think Custom models is the one I am looking for.
This is great and this what developers need when actually building custom big project (y)
Let me try it.
March 19, 2024 at 8:14 PM #44912Aishwarya
ParticipantIt seems like it doesn't support frontend submission. It created table successfully, form populated in the front-end, date picker not working and when submitting the form, it does saved to wp_posts instead of the custom table.
March 19, 2024 at 8:39 PM #44914Peter
ModeratorHello,
Currently, the custom model doesn't work with frontend submission form. You can create the model entries in the admin area.
March 19, 2024 at 9:30 PM #44919Aishwarya
ParticipantYes, I started writing my own code for that.
It would be great if you add feature to group multiple fields like a field like
[ 'id' => 'start_group', 'type' => 'start_group', //this may create flex style like <div class="flex-row"> ], [ 'id' => 'relation', 'type' => 'select', 'name' => 'relation', 'options' => [ 's-o' => 'S/O', 'd-o' => 'D/O', 'w-o' => 'W/O', ], ], [ 'id' => 'relation_name', 'type' => 'text', 'name' => 'Name', ], [ 'id' => 'start_group', 'type' => 'end_group', ],
This is a simple implementation so we can save a lot of vertical space and also it will be meaningful to have fields in horizontal grouping for fields like S/O - Name values.
I hope you understand!
March 20, 2024 at 8:29 PM #44931Peter
ModeratorHello,
In the builder, you can use the Before and After settings of custom fields to create a wrapper div. Please check this screenshot https://imgur.com/a/Tk9pBXi
If you use the code, please follow the documentation https://docs.metabox.io/field-settings/
March 24, 2024 at 8:31 PM #44990Aishwarya
ParticipantHi,
Sorry for the delay.
If it covers both the label and input means, that's what I want. Thanks so much for the information.
Have a nice weekend 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.