Group repeater in settings page
Support › MB Settings Page › Group repeater in settings pageResolved
- This topic has 7 replies, 2 voices, and was last updated 3 years ago by
Long Nguyen.
-
AuthorPosts
-
April 7, 2022 at 8:32 PM #35523
[email protected]
ParticipantI am struggling and probably out of my depth so could do with a pointer.
I am using AIO plugin.
I have a settings page with 3 tabs. On one of them I have created a cloneable group field where the day of the week along with two times can be selected multiple times (ie entering variable Opening Hours).The produced php code looks like:<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Business settings hours', 'your-text-domain' ), 'id' => 'business-settings-hours', 'settings_pages' => ['business-data'], 'tab' => 'Hours', 'fields' => [ [ 'name' => __( 'Open Hours', 'your-text-domain' ), 'id' => $prefix . 'open_hours', 'type' => 'group', 'clone' => true, 'clone_as_multiple' => true, 'max_clone' => 7, 'fields' => [ [ 'name' => __( 'Day', 'your-text-domain' ), 'id' => $prefix . 'day', 'type' => 'select', 'options' => [ 'Monday' => __( 'Monday', 'your-text-domain' ), 'Tuesday' => __( 'Tuesday', 'your-text-domain' ), 'Wednesday' => __( 'Wednesday', 'your-text-domain' ), 'Thursday' => __( 'Thursday', 'your-text-domain' ), 'Friday' => __( 'Friday', 'your-text-domain' ), 'Saturday' => __( 'Saturday', 'your-text-domain' ), 'Sunday' => __( 'Sunday', 'your-text-domain' ), ], ], [ 'name' => __( 'Open', 'your-text-domain' ), 'id' => $prefix . 'open', 'type' => 'time', ], [ 'name' => __( 'Close', 'your-text-domain' ), 'id' => $prefix . 'close', 'type' => 'time', ], ], ], ], ]; return $meta_boxes; }
From the settings page, the add more works to create extra, but upon save settings the page resets and the values do not appear to be saved (they do not seem to be able to override settings in relevant entry of wp_options table.
I then need to print these out in a looped query.
Can you please point me in the right direction?April 8, 2022 at 12:28 PM #35530Long Nguyen
ModeratorHi,
You can try to follow this tutorial to increase the PHP setting
max_input_vars
to fix the issue
https://metabox.io/wordpress-custom-fields-not-saving-increase-max-input-vars/Let me know how it goes.
April 8, 2022 at 1:33 PM #35533[email protected]
ParticipantThank you. I have tried that without success
What should I look at next?April 8, 2022 at 10:43 PM #35541Long Nguyen
ModeratorHi,
I do not see any issue when adding and saving field values with your code. Please try to deactivate all plugins except Meta Box, MB extensions, switch to the standard theme of WordPress, and run only the code above to add the custom fields to the settings page.
Then re-check this issue.April 11, 2022 at 7:22 PM #35563[email protected]
ParticipantI have tried that with no luck. I'm sure I must be doing something wrong but unsure what that must be!
April 12, 2022 at 12:37 PM #35576Long Nguyen
ModeratorHi,
Please share your site credentials via this contact form https://metabox.io/contact/
I will take a closer look.April 12, 2022 at 1:38 PM #35580[email protected]
ParticipantCOntact form sent. Thanks
April 13, 2022 at 12:29 PM #35607Long Nguyen
ModeratorResolved.
The problem happens due to there are two custom fields that have the same ID on a page.
-
AuthorPosts
- You must be logged in to reply to this topic.