function field_ui_existing_field_options
field_ui_existing_field_options($entity_type, $bundle)
Returns an array of existing fields to be added to a bundle.
File
- modules/field_ui/field_ui.admin.inc, line 1523
- Administrative interface for custom field type creation.
Code
function field_ui_existing_field_options($entity_type, $bundle) { $info = array(); $field_types = field_info_field_types(); foreach (field_info_instances() as $existing_entity_type => $bundles) { foreach ($bundles as $existing_bundle => $instances) { // No need to look in the current bundle. if (!($existing_bundle == $bundle && $existing_entity_type == $entity_type)) { foreach ($instances as $instance) { $field = field_info_field($instance['field_name']); // Don't show // - locked fields, // - fields already in the current bundle, // - fields that cannot be added to the entity type, // - fields that should not be added via user interface. if (empty($field['locked']) && !field_info_instance($entity_type, $field['field_name'], $bundle) && (empty($field['entity_types']) || in_array($entity_type, $field['entity_types'])) && empty($field_types[$field['type']]['no_ui'])) { $info[$instance['field_name']] = array( 'type' => $field['type'], 'type_label' => $field_types[$field['type']]['label'], 'field' => $field['field_name'], 'label' => $instance['label'], 'widget_type' => $instance['widget']['type'], ); } } } } } return $info; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field_ui!field_ui.admin.inc/function/field_ui_existing_field_options/7.x