On the Configurations page, if a field is re-used in multiple content types (entity_type/bundle probably), it is only shown once with the most recently added content type. As you can see in the picture of the page, the "TA Form" is the only bundle shown, yet the Field List report shows that it is actually used in four different content types. This means that I cannot have different behaviors in different instances.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stefan.r’s picture

Category: Bug report » Feature request

Just wondering if this may be related to #1280994: Allow different HS configs for different Taxonomy Term fields (instead of 1 HS config per vocabulary) (which made it go from "per vocabulary" to "per-field"), and now we're looking to do "per-field instance"?

I think the workaround for now is to use different fields, until someone posts a patch for this.

NancyDru’s picture

I saw that issue, but didn't mention it as it was closed.

My site is far too mature to add new fields; too much stuff would break. However, this was more a "gasp" moment for me since I can have it do the same in all the content types using that. But it did take me a moment to realize that I was looking at the right field.

AFAIC, a better workaround would be to show all the bundle types on the admin page, not just the most recent one.

stefan.r’s picture

Wait, this is actually possible by going to the right link, just that the admin page isn't showing it?

NancyDru’s picture

I'm not sure what you mean. On the Fields List page, yes, I can see all the entity_types that use the field. However, the HS Configurations page does not. And that is where I went to change the setting for HS.

NancyDru’s picture

Title: Configurations Page shows only the most recent content type » Configurations Page shows only last bundle and incorrect links

I've also discovered that the bundle links are incorrect if the entity type is not "node." This code fixes that, and shows each bundle type in which the term is used.

function hs_taxonomy_hierarchical_select_config_info() {
  static $config_info;

  if (!isset($config_info)) {
    $config_info = array();
    $fields = field_info_fields();
    foreach ($fields as $field_name => $field) {
      foreach ($field['bundles'] as $entity_type => $bundles) {
        $bundle_links = array();
        foreach ($bundles as $bundle) {
          $instance = field_info_instance($entity_type, $field_name, $bundle);
          if ($instance['widget']['type'] == 'taxonomy_hs') {
            $bundles_info = field_info_bundles($entity_type);
            switch ($entity_type) {
              case 'node':
                $bundle_links[] = l(t($bundles_info[$bundle]['label']), "admin/structure/types/manage/$bundle");
                break;

              case 'taxonomy_term':
                $bundle_links[] = l(t($bundles_info[$bundle]['label']), "admin/structure/taxonomy/$bundle/fields");
                break;

              case 'profile2':
                $bundle_links[] = l(t($bundles_info[$bundle]['label']), "admin/structure/profiles/manage/$bundle/fields");
                break;
              
              default:
                drupal_set_message(t('What is the correct link for @type', array('@type' => $entity_type)));              
            }
            $entity_info = entity_get_info($entity_type);
            $machine_name = $field['settings']['allowed_values'][0]['vocabulary'];
            $vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
            $config_id = hs_taxonomy_get_config_id($field_name);
            $config_info[$config_id] = array(
              'config_id'      => $config_id,
              'hierarchy type' => t('Taxonomy'),
              'hierarchy'      => t('Vocabulary') . ': ' . l(t($vocabulary->name), "admin/structure/taxonomy/$vocabulary->machine_name") . '<br /><small>' . t('Field label') . ': ' . $instance['label'] . '<br />' . t('Field machine name') . ': ' . $field_name . '</small>',
              'entity type'    => $entity_info['label'],
//              'bundle'         => l(t($bundles_info[$bundle]['label']), "admin/structure/types/manage/$bundle"),
              'bundle'         => implode('<br />', $bundle_links),
              'context type'   => '',
              'context'        => '',
              'edit link'      => isset($bundles_info[$bundle]['admin']['real path']) ? $bundles_info[$bundle]['admin']['real path'] . "/fields/$field_name/widget-type" : $bundles_info[$bundle]['admin']['path'] . "/fields/$field_name/widget-type",
            );
          }
        }
      }
    }
  }

  return $config_info;
}

I'll see if I can set up a way to actually produce a patch.

NancyDru’s picture

Status: Active » Needs review
FileSize
3 KB

This is improved from above code.

NancyDru’s picture

BTW, this does not fix the performance issue: The $config_info[$config_id] is built in its entirety for every bundle of the entity type.

  • stefan.r committed 1d112da on 7.x-3.x authored by NancyDru
    Issue #2484045 by NancyDru: Configurations Page shows only last bundle...
stefan.r’s picture

Status: Needs review » Fixed

Committed and pushed to 7.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.