I'm using Drupal 7 to create a project linking organizations to volunteers. My initial approach is to use profile module to create different profiles for each role (volunteer & organization). Is it possible to create new fields which would attach only to a selected role?
This is a great example use-case for the Profile 2 module.
As listed on the project page:
Profile2 allows for creating multiple profile types, which may be assigned to roles via permissions (e.g. a general profile + a customer profile)
I guess you could also try to add all fields to the user directly and then use a custom hook_field_access() implementation to control when they are shown for edit/view.
I think you can use https://drupal.org/project/user_role_field This module allows you to specify role specific fields. When creating a new field, you specify for what roles this field is enabled..
Sounds like a good idea to collect all fields in one entity. You could then have a enumerator-field, where you could choose entity-sub-type (organization or volunteer). That would be needed in case the author had authority to create both. You can use User Role Field to hide the fields that the author is not allowed to see. You can use Field Permissions to restrict access that the author and viewer is not allowed to access. You can use also hide or show fields dependent on values of other fields with Conditional Fields. The dependee field would then be the enumerator-field. You could probably use Computed Field to add extra logic dependent on sub-type.
I like to use taxonomy for enumerator, but it could be a text list instead.
You would probably also like to group the subtype specific fields together in a drupal.org/project/field_group
This pattern could just as well be applied on contenttypes. I think I will try it out.
In Microsoft Sharepoint, ContentTypes has had inheritance for years. I wonder if it will come in a future Drupal version.