One-to-many relationship on "bay_mb_relationships"
Support › MB Relationships › One-to-many relationship on "bay_mb_relationships"Resolved
- This topic has 5 replies, 4 voices, and was last updated 5 years, 6 months ago by
Long Nguyen.
-
AuthorPosts
-
January 29, 2020 at 5:27 PM #18052
Berg Informatik
ParticipantI try to realize a database structure like this.
https://i.stack.imgur.com/MeCoj.png
I have 3 post types:
* Workout
* Exercise
* SetThanks 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.
January 31, 2020 at 11:33 AM #18072Anh Tran
KeymasterHi,
If you want to force only one connection from one side of a relationship, please set
'max_clone' => 1to 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', ), ) ); } );January 31, 2020 at 2:01 PM #18074Berg Informatik
ParticipantThanks 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.
January 31, 2020 at 3:05 PM #18076Anh Tran
KeymasterThank 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!
April 22, 2020 at 1:38 AM #19200Robert Wilson
ParticipantUsing the example above, I'm wondering how one would go about ensuring that a workout_exercise is only created if a workout has been selected (assigned to it). Essentially, don't allow an exercise to be created without selecting a workout that it is related to. I hope that makes sense.
Thanks you for creating such a fantastic set of plugins. I would love to see more examples using "Twig".
April 22, 2020 at 10:39 AM #19213Long Nguyen
ModeratorHi Robert,
The extension only helps you to create the relation between the posts, but thanks for the idea, I will discuss with the developer team to support the property
'required' => 1to check this box not empty like the required fields. -
AuthorPosts
- You must be logged in to reply to this topic.