You are here

function flag_field_extra_fields in Flag 7.2

Same name and namespace in other branches
  1. 7.3 flag.module \flag_field_extra_fields()

Implements hook_field_extra_fields().

File

./flag.module, line 317
The Flag module.

Code

function flag_field_extra_fields() {
  $extra = array();
  $flags = flag_get_flags();
  foreach ($flags as $name => $flag) {

    // Skip flags that aren't on entities.
    if (!is_subclass_of($flag, 'flag_entity')) {
      continue;
    }

    // In order to make sense with this hook's structure, we use D7 lingo, hence
    // some translation is required...
    $entity_type = $flag->content_type;
    foreach ($flag->types as $bundle_name) {
      if ($flag->show_on_form) {
        $extra[$entity_type][$bundle_name]['form']['flag'] = array(
          'label' => t('Flags'),
          'description' => t('Checkboxes for toggling flags'),
          'weight' => 10,
        );
      }
    }
  }
  return $extra;
}