Support Forum
Support › MB Custom Table › Page Custom Fields not saving to Custom Table
I have a page with custom fields but they are not saving to the custom database. If I turn off the custom table they save correctly to the wp_postmeta table.
Here is the PHP.( I am using the Meta Box UI for everything)
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = 'tuition_';
$meta_boxes[] = [
'title' => __( 'Tuition & Fees', 'your-text-domain' ),
'id' => 'tuition-fees',
'post_types' => ['page'],
'include' => [
'relation' => 'OR',
'ID' => [725],
],
'storage_type' => 'custom_table',
'table' => 'wp_tuition_fees',
'tabs' => [
'tuition_payment_due_dates_tab' => [
'label' => 'Due Dates',
'icon' => '',
],
'tuition_community_member_tab' => [
'label' => 'Community Member',
'icon' => '',
],
'tuition_non_community_member_tab' => [
'label' => 'Non Community Member',
'icon' => '',
],
'tuition_discounts_tab' => [
'label' => 'Discounts',
'icon' => '',
],
'tuition_fees_tab' => [
'label' => 'Fees',
'icon' => '',
],
],
'fields' => [
[
'name' => __( '1 Payment Due Date', 'your-text-domain' ),
'id' => $prefix . '1_payment_due_date',
'type' => 'text',
'columns' => 3,
'tab' => 'tuition_payment_due_dates_tab',
],
[
'name' => __( '2 Payments Due Date', 'your-text-domain' ),
'id' => $prefix . '2_payments_due_date',
'type' => 'text',
'columns' => 3,
'tab' => 'tuition_payment_due_dates_tab',
],
[
'name' => __( '10 Payments Due Date', 'your-text-domain' ),
'id' => $prefix . '10_payments_due_date',
'type' => 'text',
'columns' => 4,
'tab' => 'tuition_payment_due_dates_tab',
],
[
'name' => __( '1 Payment Amount', 'your-text-domain' ),
'id' => $prefix . 'community_member_1_payment_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_community_member_tab',
],
[
'name' => __( '2 Payments Amount', 'your-text-domain' ),
'id' => $prefix . 'community_member_2_payments_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_community_member_tab',
],
[
'name' => __( '10 Payments Amount', 'your-text-domain' ),
'id' => $prefix . 'community_member_10_payments_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_community_member_tab',
],
[
'name' => __( '1 Payment Amount', 'your-text-domain' ),
'id' => $prefix . 'non_member_1_payment_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_non_community_member_tab',
],
[
'name' => __( '2 Payment Amount', 'your-text-domain' ),
'id' => $prefix . 'non_community_member_2_payments_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_non_community_member_tab',
],
[
'name' => __( '10 Payments Amount', 'your-text-domain' ),
'id' => $prefix . 'non_community_member_10_payments_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 4,
'tab' => 'tuition_non_community_member_tab',
],
[
'name' => __( 'Discounts', 'your-text-domain' ),
'id' => $prefix . 'discounts',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'add_button' => __( 'Add Discount', 'your-text-domain' ),
'fields' => [
[
'name' => __( 'Discount Name', 'your-text-domain' ),
'id' => $prefix . 'discount_name',
'type' => 'text',
'columns' => 6,
],
[
'name' => __( 'Discount Amount', 'your-text-domain' ),
'id' => $prefix . 'discount_amount',
'type' => 'text',
'columns' => 6,
],
],
'tab' => 'tuition_discounts_tab',
],
[
'name' => __( 'Fees', 'your-text-domain' ),
'id' => $prefix . 'fees',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'fields' => [
[
'name' => __( 'Fee Name', 'your-text-domain' ),
'id' => $prefix . 'fee_name',
'type' => 'text',
'columns' => 3,
],
[
'name' => __( 'Fee Description', 'your-text-domain' ),
'id' => $prefix . 'fee_description',
'type' => 'textarea',
'columns' => 6,
],
[
'name' => __( 'Fee Amount', 'your-text-domain' ),
'id' => $prefix . 'fee_amount',
'type' => 'text',
'prepend' => '$',
'columns' => 3,
],
],
'tab' => 'tuition_fees_tab',
],
],
];
return $meta_boxes;
}
Hi Dan,
Please export the field group to a JSON file and share it here. I will import it to my demo site and recheck this issue. Refer to this documentation https://docs.metabox.io/extensions/meta-box-builder/#export--import
You can also try to create another field group with a new custom table to see if it works.
Here is the custom fields JSON.
Hi Dan,
I do not see any issue when saving field value to the custom table, here is the screen record on my demos site https://monosnap.com/file/IiJjTxbIqV78hQmGmC5vbYp2pO0RNG
Can you please create a new field group with a new custom table and recheck this issue?
Did you look to see if it actually stored it in the database? I can reproduce the exactly thing in mine but when I go to the database the values are not there and after a day or so all my fields are empty again. So I guess they are getting cached somewhere.
Here is my video.
https://www.loom.com/share/22d472a5a8a740a5bf56d8abe6b1958c
Hi Dan,
Thanks for your additional info.
I've escalated this issue to the development team to investigate the issue and get back to you later.