Open Ririshi opened 1 year ago
Hello,
Thanks for the feedback and the detailed report!
I managed to reproduce the scenario you described. To manage such situation it would require an additional bounce check to remove the value if the targeted field is a "single selection".
I've planned to dust off the bidirectional setting codebase, I'll make sure to add this logic to better handle "single selection <> multiple selection" bidirectional scenarios. I'm marking this as feature request, as I'm not 100% sure that everyone would want this (it's the first time someone report it).
I'll try to think about all possible scenarios to make sure it's the most logical for everyone.
Thanks!
Regards.
Could you share any information on how much of a priority this request is, and when I can expect an update addressing this? In the meantime, I will instruct clients not to override bidirectional relationships like the one I described from the multiple selection side.
Describe the bug I created a Relationship <> Post Object Bidirectional Fields setup between two custom post types called Product and Advisor. Each Advisor can be connected to many Products, but each Product only has one Advisor. Thus, the Product CPT has an ACF field group with a post object field called
advisor
, and the Advisor CPT has an ACF field group with a relationship field calledproducts
. I linked them together using the ACF Extended Bidirectional Fields functionality.Let's say I have two Advisors, John and Jane, and a single Product called Apple.
When I select Apple in the
products
field of John, theadvisor
field for Apple is correctly updated. When I override this by selecting Apple in Jane'sproducts
field, theadvisor
field on Apple correctly updated to Jane. However, the previous Advisor, John, also still has Apple in itsproducts
relationship field, even though Apple is now connected to Jane.To Reproduce
post
andpage
types, too)products
on the Advisor CPT's ACF group, selecting Product as the only post type.advisor
on the Product CPT's ACF group, selecting Advisor as the only post type.products
field.products
field.Expected behavior When overriding an existing bidirectional connection between a relationship and a post object field, the old connection should be removed. In my example, I expect John's
products
field to be updated, removing the Apple reference when Apple is assigned to Jane.WordPress & ACF WordPress version: 6.1.1 ACF Pro version: 6.0.7 ACF add-ons: Advanced Custom Fields Multilingual: 1.10.4 Advanced Custom Fields: Gravity Forms Add-on: 1.3.5 Advanced Custom Fields: Image Aspect Ratio Crop: 6.0.2 WPGraphQL for Advanced Custom Fields: 0.6.1
Edit: Even if this will not be fixed (if it is classified as intended behaviour), please document that this is how it works. It can be confusing and based on the current documentation for Bidirectional Fields, I would have completely expected it to work the way I described.