TransWikia.com

field_info_field: how to define the content type name?

Drupal Answers Asked by Bruno von Paris on January 14, 2021

I defined several content type. In a module, I need to get the list of fields for this content type. I did the following:

 $fields = array();
  $content_type = 'indicatorsheet_page';
  $instances = field_info_instances('node', $content_type);

Variable $instances is empty. How should I defined $content_type? Isn’t it a string set to the type machine name?

One Answer

What you're doing here seems correct to me, bear in mind that you can leave the bundle parameter empty and then you'll get an array of results keyed by bundle so you can evaluate if there's a problem with the machine name of the bundle you're using:

  $instances = field_info_instances('node');

You can also access admin/reports/fields and take a look to fields and content types available in your site.

Answered by pcambra on January 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP