I am trying to call field_info_field_map() in my DefaultForm.php . What is the right way? I am getting the following error:
Error: Class 'Drupal\module_name\Form\Field' not found in Drupal\module_name\Form\DefaultForm->module_name_settings_get_field_options()
The code I am using is as follow:
$fields = Field::fieldInfo()->getFieldMap(); the code i am trying to convert to d8
function mn_settings_get_field_options() { static $options = null; if (is_array($options)) { return $options; } $options = array(); $fields = field_info_field_map(); foreach ($fields as $field_name => $field_data) { if (isset($field_data['bundles']['node'])) { $node_types = $field_data['bundles']['node']; $options[$field_name] = $field_name . ' (In content types: ' . implode(', ', $node_types) . ')'; } } asort($options); return $options; }
useat the top of the file under namespace?