As #1157660: Flag integration #8 said the fields of flag are listed only one content type on manage display ui, however the flag is added to multiple content type.
This is because of wrong ui limit array on field_info declaration:

      foreach (node_type_get_types() as $type) {
        $flags = flag_get_flags('node', $type->type);

        foreach ($flags as $name => $flag) {
          $fields['node']['ds_flag_' . $name] = array(
            'title' => t('Flag: ' . $flag->get_label('title')),
            'field_type' => DS_FIELD_TYPE_FUNCTION,
            'function' => 'ds_extras_flags_add_flag_link',
            'properties' => array(
              'flag' => $name,
            ),
            'ui_limit' => array($type->type . '|*'), // <-This array always has 1 item.
          );
        }
      }

Now I haven't idea, which would be the best way to collect the correct ui_limit value, but I'll think about it.

CommentFileSizeAuthor
#2 1710522-2.patch1.57 KBswentel
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

swentel’s picture

We should change the logic of creating the fields, instead of

  foreach (node_type_get_types() as $type) {
    $flags = flag_get_flags('node', $type->type);

it probably is better to just get all flags, iterate over them and then construct the ui_limit array, given that that info is available in $flag, but I suspect so.

  $flags = flag_get_flags('node');
  foreach ($flags as $flag) {
    $ui_limit = array();
    foreach ($flag->whatever_key_holds_the_types as $type) {
      $ui_limit[] =  $type .'|*';
    }
  }
swentel’s picture

Status: Active » Closed (fixed)
FileSize
1.57 KB

Fixed, patch attached.

warmth’s picture

Version: 7.x-2.x-dev » 7.x-2.0
Status: Closed (fixed) » Needs work

Sorry for reopening this thread but seems like all is working as expected but Flags on a User Profile page:
#1848282: Can't see the link to flag a user

swentel’s picture

Status: Needs work » Closed (fixed)

That's because only user was added here, open a new one as a feature request if you want to expose those too.

warmth’s picture

Status: Closed (fixed) » Active

I guess you didn't read the link I posted... the bug is from built-in user profile!

swentel’s picture

Status: Active » Closed (fixed)

I did, and it's not a bug, it's a feature request and has nothing todo with this issue.

warmth’s picture

Understood I will open a new thread so.