By alexmoreno, 9 January, 2013

 

Sometimes in Drupal you need to get the fields for a particular content types. 

"$type = 'mytype';

$fields = content_fields();

$type_fields = array();

foreach ($fields as $field_name => $field_data)

{

  if ($field_data['type_name'] == $type)

  {

    $type_fields[$field_name] = $field_data;

  }

}"

 

in drupal7 is easier, since we have a direct function:

field_info_instances($entity_type = NULL, $bundle_name = NULL)