2

I would like to make a field that is very similar to the group audience field but only displays certain types of groups.

As an experiment I hacked up:

og_field_audience_options

and I was able to remove the groups I didn't want but obviously this is not where this code belong.

Is there a way that I can create a new field that inherits most of the behavior of the group audience field and but has a slightly different way of picking which groups to display? Or do I need to recreate the whole field from scratch?

3

Strictly speaking, fields can't "inherit", no, but you can almost do it anyway.

Drupal 7 comes with a generic "File" field, and a more specific "Image" field. Technically, one could say that Image inherits from File, but the way it's done is simply that for a lot of it's hook implementations, it just calls back to file.

Example code:

/**
 * Implements hook_field_load().
 */
function image_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
  file_field_load($entity_type, $entities, $field, $instances, $langcode, $items, $age);
}

As far as I know, this is as close as you can get.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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