First item in Group field not being saved

Support Meta Box AIO First item in Group field not being saved

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #49909
    GeneratorGenerator
    Participant

    I have a group field and the first item isn't being saved. I have used group several times and it's the first time I've seen this issue. This is my field definition:

        $meta_boxes[] = array(
            'title' => __('Sidebar Content', 'slsh-admin'),
            'context' => 'normal',
            'priority' => 'high',
            'post_types' => array('job-opportunity'),
            'fields' => array(
                array(
                    'id' => 'position-details',
                    'type' => 'group',
                    'add_button' => 'Add a Detail +',
                    'clone' => true,
                    'sort_clone' => true,
                    'fields' => array(
                        array(
                            'id' => 'label',
                            'name' => __('Label', 'slsh-admin'),
                            'desc' => __('e.g. Location, Salary, Start Date', 'slsh-admin'),
                            'type' => 'text'
                        ),
                        array(
                            'id' => 'value',
                            'name' => __('Value', 'slsh-admin'),
                            'desc' => __('e.g. Hamilton, ON; 50,000-60,000 a year; Jan 1, 2000', 'slsh-admin'),
                            'type' => 'text'
                        )
                    )
                )
            )
        );

    And my data is being saved like this:

    a:2:{i:0;a:2:{s:5:"label";s:10:"Start Date";s:5:"value";s:11:"Jan 1, 2027";}i:1;a:2:{s:5:"label";s:8:"Schedule";s:5:"value";s:15:"Mon-Fri 9am-5pm";}}

    There should be one more item in my field value.

    #49912
    PeterPeter
    Moderator

    Hello,

    I don't see any issue when using your code to create a new field group and save the clone subfields to the database. Can you please share a screen record of the issue on your site? Does it happen with new posts or existing posts?

    #49914
    GeneratorGenerator
    Participant

    Below is how it looks in my editor. The values of first field group that I create are not saved. This happens on every post, both when creating and updating. After the post is saved, the first field group always appears empty like in the screenshot below.

    A few other things I noticed:

    I cannot remove the empty field group. If I delete it and save the post, it reappears after I refresh the editor.
    I can reorder the field groups, but after refreshing the editor, the empty one will reappear at the top.
    The empty field group has the .rwmb-clone-template class. The markup looks like this:

    <div class="rwmb-input ui-sortable" data-clone-empty-start="0">
      <div class="rwmb-clone rwmb-group-clone rwmb-sort-clone rwmb-clone-template">
        <!-- empty field group -->
      </div>
      <div class="rwmb-clone rwmb-group-clone rwmb-sort-clone">
        <!-- next field group -->
      </div>
    </div>
    #49915
    PeterPeter
    Moderator

    Hello,

    Please share your site admin account by submitting this contact form https://metabox.io/contact/
    I will take a look.

    Thank you.

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