Custom Fields
Re-Envisioned
Support MB Relationships placeholder / title

  • Creator
    Topic
  • #21680
    Resolved Aart Jan van der Linden
    Participant

    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…?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #21683
    Long 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 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.