Custom Fields
Re-Envisioned
Support MB Relationships One-to-many relationship on “bay_mb_relationships”

  • Creator
    Topic
  • #18052
    Resolved Berg Informatik
    Participant

    I try to realize a database structure like this.

    https://i.stack.imgur.com/MeCoj.png

    I have 3 post types:
    * Workout
    * Exercise
    * Set

    Thanks to the many-to-many plugin i can connect the Workout and Exercise with ease. But how can i connect the Set’s with one-to-many relation to the “bay_mb_relationships” junction table.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #18072
    Anh Tran
    Keymaster

    Hi,

    If you want to force only one connection from one side of a relationship, please set 'max_clone' => 1 to the field on that side, like this:

    add_action( 'mb_relationships_init', function () {
        MB_Relationships_API::register(
            array(
                'id'   => 'workout_to_workout_exercises',
                'from' => array(
                    'object_type' => 'post',
                    'post_type' => 'workout',
                    'field' => array(
                        'max_clone' => 1, // Limit to 1 connection only.
                    ),
                ),
                'to'   => array(
                    'object_type' => 'post',
                    'post_type' => 'workout_exercises',
                ),
            )
        );
    } );
    #18074
    Berg Informatik
    Participant

    Thanks for the tip. I just got to know the plugin. This plugin is very helpful for creating web applications with WordPress. A small minus is the missing attribute “Required” for some file types like “Map”, “Autocomplete”, “Color Picker” and “Advanced Image”. Anyway, i think i will love the plugin more and more the deeper i dive into programming.

    #18076
    Anh Tran
    Keymaster

    Thank you for your kind words and your feedback. We keep improving the plugin and will try our best to make it more useful for you!

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

Newsletter

Subscribe to our newsletter to receive news and tutorials for Meta Box and WordPress.


grid gear info copy caret-up caret-down trash