Needs review
Project:
Relation Select
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
5 Aug 2012 at 10:56 UTC
Updated:
20 May 2016 at 23:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
steveoliver commentedRelation select fields only affect the display of one node/entity/endpoint -- the "origin" (i.e. your Node A).
Relations created in Relation Select fields will be displayed only on it's entity (i.e Node A). It is up to you to further display the relation in other ways/in other places (i.e. on Node B). Additionally, Relation Select fields can be displayed on the origin endpoint in a few different ways.
Does this answer your question?
-Steve
Comment #2
steveoliver commentedbig_smile,
I misread your first post. Changing title to better reflect your issue. I'll have to look into this.
Comment #3
Jorrit commentedI am encountering this as well.
I have a directional relationship between the same node type, so from Page to Page.
Op Page 1 I create a relation to Page 2. In the database, the endpoints look like this:
When I go to edit Page 2, I see the relation as well. When I save the node, without changing anything, the endpoints table changes to:
This is because
relation_select_build_entity_keys()always adds the current entity with r_index 0. I don't think that should happen.Comment #4
Jorrit commentedPlease see the attached patch. I also fixed
relation_select_field_prepare_view()so it doesn't perform a query for data that is already available.relation_select_entity_get_relations()contains a performance problem because it usesrelation_query(), but that is part of another issue. Also,hook_field_load()doesn't need to return$items, so I removed that.Comment #5
Jorrit commentedI left in a dpm(), sorry.
Comment #6
ruben_vreeken commentedJorrit, your patch still creates som errors for me:
I'm trying to find the cause.. I'll post more if I find something useful.
Comment #7
Jorrit commentedWhat git version are you using as the base for applying the patch?
Comment #8
ruben_vreeken commentedI'm not using git (don't know where to get a git version of modules actually). I just used the branch that gets pulled in with drush and applied the patch you made.
I think I might've just fixed the issue too by the way:
What seems to happen, is that
relation_select_field_insertapplies endpoints to the relations listed in it's$itemsargument. But some of these relations (those excluded inrelation_select_entity_get_relations) are no longer loaded. The result is a standard object with an endpoints property but nothing else.Further on in the function,
field_info_instancesattempts to load fields on the relation by relation_type, but because the relation never got loaded, it doesn't have a type, and the whole thing breaks down. I think I fixed it by checking if the relation was returned byrelation_select_entity_get_relationsor not.Now to figure out how to create a patch...
Comment #9
ruben_vreeken commentedJorrit, I just cloned the module with:
And tried to apply your patch with:
But the patch won't apply. Am I doing something wrong? (the patch is meant for the 7.x-1.x-dev branch right?)
Comment #10
Jorrit commentedThere have been some commits in the git repository since I made the patch. I will see if I can recreate it, but don't expect it very soon.
Comment #11
ruben_vreeken commented@Jorrit, I'll try to roll a new patch based on your code and the code I added to fix the problem. Perhaps it's enough to mark this issue as fixed.
Comment #12
damien_dd commentedI used your patch and had an fatal error sometimes:
So i change the line:
by
Comment #13
aajones commentedThis patch fixes one problem for me, but it creates another. I have a directional relationship of "Parent", with the reverse label being "Child." My goal was to see a node's parent and children, when looking at the node. In my form, I have a relation_select field where I choose the "Parent" when editing a resource.
Prior to implementing a patch, my relations were messed up when editing a 'parent' node. The direction of the relationship became reversed on a node save, so that nodes that were "children" were ending up being "parent" nodes.
With the patch from jorrit implemented, the above undesired behavior is eliminated, but the display of the "children" nodes is also eliminated entirely; I can only see 'parent' nodes of the current node, and not its children.
The problem is in the function relation_select_field_prepare_view . It should be left unchanged from the original code.
This patch is applicable against the 7.x-1.x-dev version that's listed on the module's main page (2013-Jul-24)
Comment #14
aajones commentedIs there any progress on this issue? I updated a production site (yes, I tested first), but didn't notice the reversal of the relationship on the nodes until we had edited approximately 300 nodes, which resulted in all of our relationships being messed up. It would be nice to have this issue resolved, so in the case that I accidentally update this module (again), it will not result in such a catastrophe. There are only a few lines of code which need to be changed. Please see my suggested patch, above.
Thanks for the consideration
Comment #15
nadavoid commentedUpdated the patch of #13 to account for add/edit forms as well as display.
Comment #16
nadavoid commentedTo address the original question, "when I go to edit page A, I don't want its relationship to B to be shown" no, I don't think this module will do that. It currently allows you to select the *target* of a relation. I think this assumption is baked in in a lot of places throughout the module, but not everywhere. I think that the thing to think about would be to add an option to the field configuration to select wether you want to be selecting targets or sources of relations.
Comment #17
nadavoid commentedReroll of my patch in #15, making it relative to the module root.