In hook_field_formatter_info(), it's important to use keys that don't conflict with other modules. This may have been less important in 6.x (I dunno if that's the case or not) but D7 tracks the formatters by key alone, so modules naming them the same will cause problems.

I've been running into a problem on a site where link.module is defining 'default' and screwing up fivestar (of course, fivestar using 'default' is also a bug. I have reported that as #1063754: Field formatters not unique just now.)

BTW, I did some analysis across the entire contrib repo and came up with this list of known hook_field_formatter_info() implementations that may be relevant to D7.
http://drop.rtk0.net/field_formatter_implementations.html

'default' is definately conflicting with several other modules. Some of the others may or may not conflict, but it's best practice in D7 to use a proper prefix on them so there isn't any chance of conflicts.

Comments

bdragon’s picture

Status: Active » Needs work
StatusFileSize
new2.41 KB

Here's something I'm using locally to compensate. I haven't tested it thoroughly, and I haven't considered the necessary migrate / _update_nnn changes, so it's CNW.

jcfiala’s picture

Yeah, I see what you mean. That got missed in the original updating.

I'm not _as_ worried about updates, because my feeling is that alpha code is a little radioactive, but I'll look and see how that can be fixed. The translation is at least as simple as slipping a link_ at the beginning of it.

jcfiala’s picture

I think instead of your change I might change the names of the theme functions so it's still the clean 'link_formatter_link_default', etc, so it's just 'link_formatter_'. $display['type']

jcfiala’s picture

Assigned: Unassigned » jcfiala

And... this looks like I could use it in an update to make changes:

$fields = field_read_fields(array('type' => 'link_field'));
  foreach ($fields as $field_name => $field_data) {
    $instances = field_read_instances(array('field_id' => $field_data['id']));
    foreach ($instances as $instance_index => &$instance) {
      foreach ($instance['display'] as $display_type => $display) {
        $instance['display'][$display_type]['type'] = 'link_'. $instance['display'][$display_type]['type'];
      }
      field_instance_update($instance);
    }
  }

I think first I need to step back and fix the other bit where I moved the settings around first.

jcfiala’s picture

Status: Needs work » Fixed

Okay, I've made a fix for this and comitted it to the codebase. Should show up in dev soon.

Status: Fixed » Closed (fixed)

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

yched’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1017 bytes

Attached patch updates the content_migrate integration accordingly, so that migrated fields get the correct D7 formatters.

yched’s picture

Status: Needs review » Closed (fixed)

Included the fix (along with other migration fixes) in #1230256: Fix D6 migration (cck_migrate).
Closing back this thread.