placeholder / title

Support MB Relationships placeholder / titleResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21680

    Hi!

    I sometimes wonder if I'm doing something wrong or if I misunderstand your way of thinking:

    This code

    add_action( 'mb_relationships_init', function() {
                \MB_Relationships_API::register( [
                    'id'   => 'network_in_theme',
                    'from' => [
                        'object_type' => 'post',
                        'post_type'   => 'network',
                        'meta_box'    => [
                            'title' => 'in Theme:',
                        ],
                        'field' => [
                            'placeholder' => 'Select a Network'
                        ]
                    ],
                    'to'   => [
                        'object_type' => 'post',
                        'post_type'   => 'researchtheme',
                        'meta_box'    => [
                            'title' => 'Networks:',
                        ],
                        'field' => [
                            'placeholder' => 'Select a Theme'
                        ]
                    ],
                ] );
            } );

    creates a perfect working metabox on both the network and the theme admin page.
    Network page:
    - metabox title "in Theme:"
    - field placeholder "Select a Theme"

    Theme page:
    - metabox title "Networks:"
    - field placeholder "Select a Network"

    To me, this seems a bit counter-intuitive if I look at the code...?

    #21683
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The relationship field settings have a bit different from the regular field settings which are inside the meta box settings https://docs.metabox.io/creating-meta-boxes/. That's why it has the same level as the setting meta box.

    'meta_box'     => [
        //settings
    ],
    'field' => [
        //settings
    ]

    Understand it correctly, it gets the post type researchtheme and field settings to to show on the post type network from as a custom field.

    #21763

    Thanx, I now understand your way of looking at it.

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