Custom Fields
Re-Envisioned
Support Meta Box Builder clone _as_multiple not working

  • Creator
    Topic
  • #21636
    Resolved toni bird
    Participant

    Hi there, tried a few times to save clone as multiple, but does not work, data on database still the same serialized string.. code :

     [
                    'id'                => $prefix . 'rdo_staff_group_D',
                    'type'              => 'group',
                    'fields'            => [
                        [
                            'id'         => $prefix . 'rdo_staff_D',
                            'name'       => esc_html__( 'Funcao', 'text-domain' ),
                            'type'       => 'select_advanced',
                            'options'    => [
                                'armador'  => esc_html__( 'Armador', 'text-domain' ),
                                'soldador' => esc_html__( 'Soldador', 'text-domain' ),
                            ],
                            'js_options' => [
                                'size' => 25,
                            ],
                            'columns'    => 3,
                            'add_button' => esc_html__( '+ funcoes', 'text-domain' ),
                            'size'       => 25,
                        ],
                        [
                            'id'      => $prefix . 'rdo_staff_DH',
                            'type'    => 'number',
                            'name'    => esc_html__( 'HHT', 'text-domain' ),
                            'min'     => 1,
                            'max'     => 9,
                            'step'    => 1,
                            'columns' => 5,
                            'visible' => [
                                'when'     => [['rdo_staff_D', '!=', '']],
                                'relation' => 'and',
                            ],
                        ],
                    ],
                    'clone'             => 1,
                    'default_state'     => 'collapsed',
                    'collapsible'       => true,
                    'group_title'       => '{rdo_staff_D}',
                    'add_button'        => esc_html__( '+ adicionar MO', 'text-domain' ),
                    'save_state'        => true,
                    'tab'               => 'rdo_staff_tab',
                    'clone_as_multiple' => true,
                ],

    result : a:1:{i:0;a:2:{s:11:”rdo_staff_D”;s:7:”armador”;s:12:”rdo_staff_DH”;s:1:”9″;}}

    Any help?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #21646
    Long Nguyen
    Moderator

    Hi,

    The field group is a special field, it always saves the data in a serialized string. If you use the setting clone_as_multiple, instead of showing all data in a string, it will save data in more rows for each clone.

    Use clone_as_multiple:

    a:1:{i:0;a:2:{s:11:”rdo_staff_D”;s:7:”armador”;s:12:”rdo_staff_DH”;s:1:”9″;}}
    a:1:{i:0;a:2:{s:11:”rdo_staff_D”;s:7:”armador”;s:12:”rdo_staff_DH”;s:1:”9″;}}

    Not use:

    a:2:{i:0;...; i:1...}

    For more information, please follow this documentation https://metabox.io/introducing-clone-as-multiple-feature/.

    #21663
    toni bird
    Participant

    Hi, thanks again, got it sorted using a different approach .

    cheers

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