Skip to content

Instantly share code, notes, and snippets.

@andeersg
Last active December 31, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andeersg/7986096 to your computer and use it in GitHub Desktop.
Save andeersg/7986096 to your computer and use it in GitHub Desktop.
List out two arrays with all the field data you need for hook_install().
include_once DRUPAL_ROOT . '/includes/utility.inc';
$nodetype = '';
$instances = field_info_instances('node', $nodetype);
$fields = array();
foreach ($instances as $instance) {
unset($instances[$instance['field_name']]['id'], $instances[$instance['field_name']]['field_id']);
$field_data = field_info_field($instance['field_name']);
unset($field_data['id']);
$fields[$instance['field_name']] = $field_data;
}
dpm(drupal_var_export($fields));
dpm(drupal_var_export($instances));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment