I need some explanation for understanding your module.

I created three content types
"Leagues"
"Teams" with a nodereference field to content type "Teams" (Team is paticipant of a certain league)
"Pairs" with three reference fields: pairleague (node reference to content type "Leagues"), team_home (node reference to content type "Teams") and team_guest (node reference to content type "Teams")

In Option Trim admin settings
First step for content type "Pairs": Set the parent for "team_home" and "team_guest" to select field "pairleague"

But I don't understand the second step. Why must I set the referenced Items (Teams to League) again, although they are already referenced by their node reference field in content type "Teams" ?

If I add a new Team (node), I'll have to add the relation in Option Trim settings too (again). That's not userfriendly, because Teams are added by Users, but Option Trim settings are edited only by admin.

Comments

cyu’s picture

Category: support » feature

So to understand your request, let me try to summarize how you'd like to see this work.

In configuration, you'd like there to still be a parent select and a child select. If both the parent and child selects are node references, look at the content type that the child select is referencing and see if it has another field in it which is a node reference to the same content type that the parent select is referencing. If it does, give the option in the field configuration to "use Teams nodes to dictate trimming" or something to that effect instead of giving a config screen for individual options. Now, every time a "Pairs" node is loaded, instead of querying for option trim values...load every "Teams" node and generate pairs based on the league.

This really isn't something that this module sets out to do. For all select fields, node reference, user reference, or text selects, it will be an issue whenever the select lists change and an admin will need to reconfigure the option trimming. I don't like the idea of loading every node of a certain content type each time a node of a different content type is loaded either, so unless you can think of a different way to implement this I don't think I'll include this feature.

Micha1111’s picture

Yes, that's what I mean:
If the child select type has itself a reference to the parent select type, use this reference automatically without a separate or second configuration.

I don't know much about php, so I don't know, if it is easy or difficult to code this feature, but there are to other modules, which can do something like this:
"Hierarchical Select" and "Active Select"
Unfortunately Hierarchical Select deals only with taxonomy fields, not nodereference fields.
Active select deals only with the category module (but categories are saved as nodes !!)
So I think this feature should be possible.

I think "loading every node" all the time is not necessary.
You need the functionality of trimming only in the one add- or edit-form.
If the form is submitted, only the nid's of the referenced field / nodes are stored in database, like the same as in usual nodes with nodereference fields. Can this be a performance problem ?

cyu’s picture

Status: Active » Closed (works as designed)

Every time you create/edit a "Pair" you will have to load every "Team" in order to see what league they belong to so that you can properly establish how to trim team_home and team_guest based on pairleague. The other option is to create all of those team=>league relationships whenever the option trim is first configured and then update the relationships every time a team is added or edited. The first is a performance issue, the second is not something I have any desire to code.

As I said earlier though, that really isn't the aim of this module. It is meant to trim select boxes which are controlled by an admin who can also configure option trim whenever those select boxes change.