Multiple frontend & nested values
Support › MB Frontend Submission › Multiple frontend & nested valuesResolved
- This topic has 2 replies, 1 voice, and was last updated 1 year, 8 months ago by
Yasmine.
-
AuthorPosts
-
August 9, 2023 at 3:38 PM #42853
Yasmine
ParticipantHi there!
I need to create multiple frontend forms that share the same custom fields. I have run a couple of tests with identical setup:
Test 1:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Test 1', 'your-text-domain' ), 'id' => 'test_form_1', 'post_types' => ['research'], 'fields' => [ [ 'name' => __( 'Title', 'your-text-domain' ), 'id' => $prefix . 'post_title', 'type' => 'text', ], [ 'name' => __( 'A cloneable value', 'your-text-domain' ), 'id' => $prefix . 'a_cloneable_value', 'type' => 'group', 'fields' => [ [ 'name' => __( 'Option 1', 'your-text-domain' ), 'id' => $prefix . 'option_1', 'type' => 'text', ], [ 'name' => __( 'Nested', 'your-text-domain' ), 'id' => $prefix . 'nested ', 'type' => 'group', 'clone' => true, 'fields' => [ [ 'name' => __( 'Option 2', 'your-text-domain' ), 'id' => $prefix . 'option_2', 'type' => 'text', ], ], ], ], ], ], ]; return $meta_boxes; }
Test 2:
<?php add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' ); function your_prefix_function_name( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => __( 'Test 2', 'your-text-domain' ), 'id' => 'test_form_2', 'post_types' => ['research'], 'fields' => [ [ 'name' => __( 'Title', 'your-text-domain' ), 'id' => $prefix . 'post_title', 'type' => 'text', ], [ 'name' => __( 'A cloneable value', 'your-text-domain' ), 'id' => $prefix . 'a_cloneable_value', 'type' => 'group', 'fields' => [ [ 'name' => __( 'Text', 'your-text-domain' ), 'id' => $prefix . 'option_1', 'type' => 'text', ], [ 'name' => __( 'Group', 'your-text-domain' ), 'id' => $prefix . 'nested', 'type' => 'group', 'clone' => true, 'fields' => [ [ 'name' => __( 'Text', 'your-text-domain' ), 'id' => $prefix . 'option_2', 'type' => 'text', ], ], ], ], ], ], ]; return $meta_boxes; }
But my issue is that the nested field values are not saved across the form. So the
option_2
saves in one form but does not save / update in the other. I tried changing the IDs incase of a conflict. Is this a bug or something I am doing wrong? Wanting to understand before going ahead and building a lot of form duplicates!Many thanks,
YasmineAugust 9, 2023 at 3:42 PM #42854Yasmine
ParticipantAnd just incase it matters -
option_1
value showsAugust 9, 2023 at 4:01 PM #42855Yasmine
ParticipantYou can close this - there was a space after the id
nested
.I changed the option_2 ID but not the group - until now..
Think it would be useful if IDs were trimmed of white space upon save though!
-
AuthorPosts
- You must be logged in to reply to this topic.