hook_field_info needs to return a property type to work well with entity & token modules

Created on 11 October 2016, over 8 years ago
Updated 13 February 2025, 27 days ago

Currently, iban_field_field_info doesn't return a property_type.

In my setup I noticed 2 things that are related but I didn't though so in the begining.

First, in status page (admin/reports/status),
I noticed that Tokens were reporting a problem:

The following tokens or token types are missing required name and/or description information:

$info['tokens']['entityform']['field-iban']

Secondly, in the watchdog log (admin/reports/dblog) I had these php notices:

Notice: Undefined index: label in entity_views_field_definition() (line 191 of [path]/entity/views/entity.views.inc).

Notice: Undefined index: label in entity_token_token_info_alter() (line 99 of [path]/entity/entity_token.tokens.inc).

After some debuging, I found out that "label" is required, and the field responsible for not having label is field_iban.

I've backtraced the issue to the iban_field_property_callback, which should return a label. I've noticed that other modules are having almost identical code which didn't return a label as well, so I imagined that the label should already be present in
$property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']];
but.. it wasn't as it should be.

After some more digging, I saw that entity module calls the entity_metadata_field_default_property_callback before calling other property callbacks, but because there is no property_type, entity_metadata_field_default_property_callback doesn't do anything.

So... we should make it return a property_type (patch to be posted in a few minutes).

Some more information I found:
http://www.drupalcontrib.org/api/drupal/contributions!entity!entity.api....

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇨🇭Switzerland Zekvyrin Switzerland / Greece

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024