function field_system_info_alter
Implements hook_system_info_alter().
Goes through a list of all modules that provide a field type, and makes them required if there are any active fields of that type.
Related topics
File
-
modules/
field/ field.module, line 366
Code
function field_system_info_alter(&$info, $file, $type) {
if ($type == 'module' && module_hook($file->name, 'field_info')) {
$fields = field_read_fields(array(
'module' => $file->name,
), array(
'include_deleted' => TRUE,
));
if ($fields) {
$info['required'] = TRUE;
// Provide an explanation message (only mention pending deletions if there
// remains no actual, non-deleted fields)
$non_deleted = FALSE;
foreach ($fields as $field) {
if (empty($field['deleted'])) {
$non_deleted = TRUE;
break;
}
}
if ($non_deleted) {
if (module_exists('field_ui')) {
$explanation = t('Field type(s) in use - see <a href="@fields-page">Field list</a>', array(
'@fields-page' => url('admin/reports/fields'),
));
}
else {
$explanation = t('Fields type(s) in use');
}
}
else {
$explanation = t('Fields pending deletion');
}
$info['explanation'] = $explanation;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.