From and To fields reversed...?

Support MB Relationships From and To fields reversed...?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #49202
    A.A.
    Participant

    When creating a relationship using the UI, both From and To sides have three tabs: General, Meta Box, and Field. The "Field" part appears reversed, so whatever I add in the From > Field section is appearing on the To > Field section in the post edit pages..

    For example, here is the generated code of the relationship I was trying to set up between two post types: Course and Lesson. My plan was to let a Course contain many lessons, but have it so lessons can only belong to one course:

    <?php
    add_action( 'mb_relationships_init', 'your_prefix_register_relationships' );
    
    function your_prefix_register_relationships() {
        MB_Relationships_API::register( [
            'from'        => [
                'post_type' => 'course',
                'meta_box'  => [
                    'title'   => 'Lessons in this Course',
                    'context' => 'normal',
                ],
                'field'     => [
                    'max_clone'  => 1,
                    'add_new'    => false,
                    'add_button' => 'From Add More Text',
                    'name'       => 'From Label',
                ],
            ],
            'to'          => [
                'post_type'    => 'lesson',
                'admin_filter' => true,
                'admin_column' => 'after title',
                'meta_box'     => [
                    'title' => 'Course',
                ],
                'field'        => [
                    'add_button' => 'To Add More Text',
                    'add_new'    => false,
                    'name'       => 'To Label',
                ],
            ],
            'id'          => 'course-to-lesson',
            'delete_data' => false,
        ] );
    }

    NOTE: I temporarily used 'From Add More Text', 'From Label', 'To Add More Text', and 'To Label' to better help describe my issue without having to upload screenshots.

    While the above code is ordered properly, when I go to the Course edit page I see the expected meta box title, 'Lessons in this Course', but the dropdown inside of it has the 'To Label' and the 'To Add More Text'.

    And on the lesson page, the meta box is titled 'Course', as expected, but it has the 'From Label'.

    In other words:
    - The from meta box appears when editing the "from" post type (course). [expected behavior]
    - The field inside it shows related "to" items (lessons). [expected behavior]
    - But the field configuration (labels, clone settings, add-new text) is applied in reverse — the "to" field settings are used on the "from" meta box and vice versa. [NOT the expected behavior]

    Is it meant to be this way?

    I was expecting:
    - The "from > field" settings would appear on the "from" object's edit screen.
    - The "to > field" settings would appear on the "to" object's edit screen.

    It is causing me a lot of confusion. Is this a bug or am I using MB Relationship incorrectly?

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.