1:N Relationship not Working as Expected
-
Hello,
First I have to say: what a nice little plugin! All seems to be working excellent except one situation, here it is:
I have a 1:N relationship between 2 CPTs, Courses and Terms.
- Each Course can have several Terms
- Each Term can be assigned only to one Term.
- For the Course I use Relationship field (without any limits)
- For the Term I use Post Object field (no multiple selections allowed)
Lets have a simple situation:
- 2 courses (A, B)
- 4 terms (1,2,3,4)
- All 4 terms are are assigned to Course A.
Action:
I open the Course B and select Term 1, then save.What I would expect:
- After attemting to save the course I should be alerted that I cannot select the Term 1, because it’s already assigned to another course.
OR
- Course is saved, but the relationship field is left empty, no new term was added.
OR (best solution)
- The Term 1 should be grayed out in the select list (in fact all 4 courses should be) as it is used by another course and cannot be added.
What really happens:
- Term 1 still has only Course A assigned (which is correct)
- Course A has all 4 terms assigned (also correct)
- Course B has Term 1 assigned (not correct)
When I changed the behaviour to overwrite the settings it all worked as expected:
- Term 1 has Course B assigned
- Course A has only 3 terms assigned (2,3,4)
- Course B has Term 1 assigned
Here is the filter I used:
add_filter('acf-post2post/overwrite-settings', 'bleye_acf_post2post_overwrite'); function bleye_acf_post2post_overwrite($settings) { $settings['termin_kurz'] = array( 'overwrite' => true, ); return $settings; }
So, is this an intended behaviour? It doesn’t seem to me. For now, I will get by by overwriting the settings, but I would prefer, it wasn’t be possible to select the posts which are already in use (when overwriting is disabled).
Could you please look into it and give me some feddback?
Thank you very much
Petr
- The topic ‘1:N Relationship not Working as Expected’ is closed to new replies.