The Field Collections module defines a bundle called "field_name". This conflicts with the fields entered via the Field UI administration interface and can lead to strange bugs.

I have hit this issue once myself and it is likely to be affecting others in the wider community. So this is just a heads up on that issue, as mine and your modules are likely to be in the firing line for any potential issues, as the first choice of a name field in a user bundle is well, "Name" / "field_name".

It has been reported, #1422870: field_name is not right for any modules to use by default, but is likely to be a hard refactor of that module to reuse another bundle key.

Comments

hass’s picture

Issue summary: View changes
Status: Active » Fixed

You need to expect that the username changes. This is why we have format_username() function.

hass’s picture

I'm not sure how this is related to realname...

Alan D.’s picture

@hass
This was just a heads up for the maintainers at the time I discovered this in the Name modules issue queue.

I had issues with people installing Field Collection module after adding a field with the name "field_name" and they hit the Name modules queue with issues related to this.

If I wasn't clear above, the FC module uses field_name as a entity property key, and internal checks within the Field system go crazy when this bundle key clashes with an existing field key. Multiple notices, data loss, etc.

i.e.


/**
 * Implements hook_entity_info().
 */
function field_collection_entity_info() {
  $return['field_collection_item'] = array(
    'label' => t('Field collection item'),
    'entity keys' => array(
      'id' => 'item_id',
      'revision' => 'revision_id',
      'bundle' => 'field_name', << This clashes with the Field UI added fields if they are called field_name
    ),
...
}

Absolutely no way related to output from the function / token ;)

hass’s picture

Yeah, but how does this clash with realname?

Alan D.’s picture

Nothing... Pure UX thing as this is a common use-case.

User:
Um. This RealName module looks really cool, I want to use it by putting a name field on something...
Adds a field called Name, defaults to field_name.
Um, Field collection looks darn useful too.
Enables it.
Bang multiple issues.

i.e. Name module & RealName module both suggest that users are going to add a field onto something, the field label that comes to mind is "Name (field_name)". This then triggers errors if they latter add Field Collection module.

So, I added this to the Name field modules page to give users the heads up.

Field Collections

If you are planning to use the Field Collections module, never create a field with the machine name "field_name".

Any field with this machine name will conflict with that module, irrespective of the field type.

Alan D.’s picture

And to resolve this... Delete the field Name and create a new one that doesn't use the field name "field_name".

Kinda a real bummer for newbies that would not be able to handle a data migration between fields and loss data / pain in the butt for experienced developers that have to waste 30 min doing a migration...

Dave Reid’s picture

This should be a big red warning on the field collection module since it's responsible for this issue then, and not realname.

Alan D.’s picture

It is not possible to install FC then create a field called field_name. Internally checks withing the Field system prevent this.

Anyways, u both have made it clear that you do not consider it to be an issue for this module. Would close but hass already has ;)

hass’s picture

I'm fine with adding this as a compatibility note to the readme if sooo important, but I think fc should fix this... Why are you not fixing it in fc? Personally I never recommend creating a name field. Always create firstname and lastname fields. Otherwise you will run against walls very very soon.

Aside I'm using addressfield at the very best :-)

Status: Fixed » Closed (fixed)

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

Alan D.’s picture

Why are you not fixing it in fc?

Don't know enough about it to try...

Name module provides a 6 component name element; title, first, middle, last, generational and credentials with PHP date like formatters. You just select the display type for title surname; just first name; first name with fallback to surname; or whatever u require :)