I'm attempting to display a dropdown box of available fields based on a supplied content type. I'd like to retrieve these fields programmatically.

I'm able to get a list of available fields based on a node like so

$fields = array_keys($thisnode->getFields());

But I want to be able to get the fields based on a content type not based on a specific node.

I did see that it could be accomplished in Drupal 7 like so

$fields = field_info_instances('node', 'content-type');

based on an answer here Drupal 7 Is the a way to programmatically know the Fields in a Content Type?

However it seems like field_info_instances is not available in Drupal 8. I attempted using it and it said that the method is unavailable. Is there a method similar to field_info_instances in Drupal 8 that I can use to retrieve the fields of a specified content type?



Browse other questions tagged or ask your own question.