Search code examples
drupaldrupal-7

Drupal - field_info_field() returns NULL but field exists


If I understand correctly field_info_field loads field information from cache.

The problem occurs when trying to reach a taxonomy autocomplete for field abc:def where abcis a field collection and def afield inside it.

The url then is: .../index.php?q=taxonomy/autocomplete/abc%3Adef/search_term

Drupal returns:

Taxonomy abc:def not found.

I narrowed down the error to a call of field_info_field() which returns Null for abc:def, which definitely exists. It just does not seem to be in the cache somehow. Any idea on how to proceed?

I of course cleared the cache, it did not help.


Solution

  • field_info_field expects a field_name, field collection has no place here

    field_info_field($field_name)
    

    and as a bonus information, the field def instance won't exist in the taxonomy at all, it will exist ONLY in the field collection so if you need the field instance info, you get it this way:

    $info = field_info_instances('field_collection_item', 'abc', 'def');