field_ui_existing_field_options
- Versions
- 7
field_ui_existing_field_options($obj_type, $bundle)
Return an array of existing field to be added to a bundle.
Code
modules/field_ui/field_ui.admin.inc, line 777
<?php
function field_ui_existing_field_options($obj_type, $bundle) {
$options = array();
$field_types = field_info_field_types();
foreach (field_info_instances() as $existing_obj_type => $bundles) {
foreach ($bundles as $existing_bundle => $instances) {
// No need to look in the current bundle.
if (!($existing_bundle == $bundle && $existing_obj_type == $obj_type)) {
foreach ($instances as $instance) {
$field = field_info_field($instance['field_name']);
// Don't show locked fields or fields already in the current bundle.
if (empty($field['locked']) && !field_info_instance($obj_type, $field['field_name'], $bundle)) {
$text = t('@type: @field (@label)', array(
'@type' => $field_types[$field['type']]['label'],
'@label' => t($instance['label']), '@field' => $instance['field_name'],
));
$options[$instance['field_name']] = (drupal_strlen($text) > 80 ? truncate_utf8($text, 77) . '...' : $text);
}
}
}
}
}
// Sort the list by field name.
asort($options);
return $options;
}
?>Login or register to post comments 