I have created a One To Many relationship between two post types via builder with ID facilities2states
One State can have multiple facilities.
One Facility can have one state.
using the following settings:
Facility>Max Items: (empty for unlimited items)
State>MaxItems: 1 (one to many)
If I try to edit a Facility, as expected, there is no Add More button for state, which is what I intented to have;
Because I know of no way to add a relationship to admin columns except code, I generated the php code for the newly created relationship, and this is what I got;
<?php
add_action( 'mb_relationships_init', 'facilities2states2code' );
function facilities2states2code() {
MB_Relationships_API::register( [
'id' => 'facilities2states2code',
'from' => [
'object_type' => 'post',
'post_type' => 'facility',
'empty_message' => 'No facility selected',
'field' => [
'name' => 'Facilities',
],
],
'to' => [
'object_type' => 'post',
'post_type' => 'state',
'empty_message' => 'No state selected',
'field' => [
'name' => 'State',
'max_clone' => '1',
],
],
] );
}
For comparing purposes, I changed the relationship id from
facilities2states to facilities2states2code
in order to compare the two behaviors;
The newly created relationship allows adding more States to the Facility post type, which is not the expected behavior:
While this is obviously e code generation bug or a plugin bug, my problem would easily be solved if there would be a way to add a builder created relationship to the admin columns;