Way to re-use field groups?

Support General Way to re-use field groups?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31261
    alpha.mediaalpha.media
    Participant

    Hello,

    I am wondering if there is a way with this plugin or add-ons to define a group of fields and re-use them in another settings box?

    I am building out a settings page that will have multiple meta boxes placed in various locations on it. Some of these boxes will have the exact same settings. I cannot use a repeater field because the order of content needs to be in a certain order.

    Is it possible to define a group of fields and re-use them in multiple places like this?

    #31268
    Long NguyenLong Nguyen
    Moderator

    Hi,

    With the Builder, you can assign a field group (meta box) to more settings pages to re-use the field group. Like this https://share.getcloudapp.com/6quv9bwO

    Using code:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
    function your_prefix_function_name( $meta_boxes ) {
        $meta_boxes[] = [
            'title'          => __( 'Field Settings page', 'your-text-domain' ),
            'id'             => 'field-settings-page',
            'settings_pages' => ['my-custom-settings', 'my-settings-2'],
            'fields'         => [
                ...
            ],
        ];
        return $meta_boxes;
    }

    Please read more on the documentation https://docs.metabox.io/extensions/mb-settings-page/#creating-settings-fields

    #31296
    alpha.mediaalpha.media
    Participant

    Thanks,

    I assume that means though I can't assign it to multiple places on the same settings page?

    For instance, our settings page is to choose modules to be in specific places on the homepage and those modules are the same settings that are re-usable in the specific places they can go. It looks like I can't do that currently.

    #31313
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The field ID (meta key) is associated with the post/page ID or option name (setting page) so it's not possible to use the same field ID in other places on a page.

    You can try to use the cloneable feature to duplicate a field or a group.
    https://docs.metabox.io/cloning-fields/

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