Closed (fixed)
Project:
Relation Select
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
10 Aug 2012 at 05:52 UTC
Updated:
1 Oct 2012 at 17:47 UTC
Jump to comment: Most recent file
When configuring an instance of a Relation Select field on the manage fields form on an entity type the "Relation type" select box is only population relations that exist in the database. (It's populating this form element via relation_select_get_relation_types() )
Relation types that live in code by using features or perhaps a custom module that defines the relation type are not allowed to be used at all.
Relation types that exist in code need to be considered in relation_select_get_relation_types().
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | relation_select-types-in-code-1721824-3.patch | 1.63 KB | vordude |
| #1 | relation_select-types-in-code-1721824-1.patch | 1.48 KB | vordude |
Comments
Comment #1
vordude commentedWelp, something like this ought to do it.
Essentially we're taking the list of relations that the system knows about by using the relation_get_types() api function from the relation module instead of querying the database directly.
Then sort through all of the relations to see which ones would apply to this entity bundle.
It would be super sweet if there was a way to do this without sorting through every relation type, but I'm not sure you can.
Querying the database is certainly more efficient memory-wise but doesn't pick up relation types that are in code.
Comment #2
steveoliver commentedLooks good to me. Works as described. Anyone see anything wrong with it? I think we need to start implementing tests and maybe even requiring tests for patches/new commits.
Comment #3
vordude commentedYes. I do. This is way better...sorry.
I say use the Relation API as much as possible.
Comment #4
vordude commentedComment #5
steveoliver commentedOh, yeah, that's more like it!
Comment #6
steveoliver commentedWe get all relation types available for an entity type by calling the Relation API, not from a direct db_select(), so that relation types that are not in the database (i.e. in code) can be options when configuring a relation select field.
Committed to 7.x-1.x in f5368a5. Changing title.
Thanks, vordude.
Comment #7
Jorrit commentedThe function
relation_select_add_relation_form()still refers torelation_select_get_relation_types(). I guess this is a matter of a simple replace?Comment #8
steveoliver commentedYou were right, Jorrit. Thanks. The last two remaining instances of
relation_select_get_relation_typeshave been replaced in b59b042.