2

Premise: I'm new in the world of Drupal, so sorry if this is a stupid question.

What I need is to set some relationships for some new content types I created. For example, I created the "Person" content type and the "Group" content type. Using the "Relation" module I have defined the relation "is in", but now if I want to add a field for setting the relation at creation time, there are no edit widget available. The only way I found to set relationships is using the entity collector: too complicated for a user.

Example: a user creates the Person "John", and he want for him to set the relation "is in" with the Group "Drupal fans". So, during the creation of this Person he needs, for example, a select control that lets him to choose from all the groups already registered in the site.

In brief, I need to manage some entities created by me, with CRUD controls, list, etc. and I need to set some relationships from these entities.

What is the best method/ what are the best module/ how I can do this?

2
  • Are you using Drupal 7? Commented Aug 10, 2012 at 16:13
  • Yes, Drupal 7.15. I've installed the module Relation, I do not understand if it useful for my goal.
    – tonidi
    Commented Aug 10, 2012 at 19:31

1 Answer 1

0

I hope I'm understanding your question correctly... you'd like to know what's the best way, in Drupal 7, to add a reference to a node of another content type when creating this content type? (i.e. to store a reference to a 'Group' when creating a new 'Person')?

If that's what you're trying to do, a good way to do that in Drupal 7 is using the Entity reference module.

Once you download and enable this module, you'll be able to go to the 'Manage fields' tab of your 'Person' content type and select to create a new field of type 'Entity Reference'. That field option will only appear once you've enabled the module. Before hitting 'save' after you've selected that field type, make sure you notice that you'll have two options for the field widget: you can select for it to be a 'Select list' in which case, it will just have a drop-down list of all the Groups currently available on your system for you to choose from when creating a person. Or you could choose 'Autocomplete', which works better if you have a TON of groups and don't want a super long list. That'll allow the user to start typing the name of a group, and it will just automatically detect and complete it. :-)

Once you've selected those two options on the first screen, on the second screen you should select 'node' as the 'Target type' and select 'Group' as the type of the referenced node. Finally, just choose whether you want that field to be required or not and whether you should select only one or multiple values (like any other field).

Let me know if that works for you, and I hope I understood your question correctly!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.