diff --git a/eck.bundle.inc b/eck.bundle.inc index d3898a7..0e9b536 100644 --- a/eck.bundle.inc +++ b/eck.bundle.inc @@ -295,6 +295,22 @@ function eck__bundle__edit_form($form, &$form_state, $entity_type_name, $bundle_ '#value' => $bundle, ); + // Create a list of properties for this bundle. + $properties = array(); + foreach ($entity_type->properties as $property => $info) { + $properties[$property] = $property . ' (' . $info['label'] . ')'; + } + // Determine which managed fields should be checked by default. + $default_properties = (!empty($bundle->config['managed_properties']) && is_array($bundle->config['managed_properties'])) ? array_intersect_key($bundle->config['managed_properties'], $properties) : array(); + // Add configuration to manage property display through the manage field forms. + $form['config_managed_properties'] = array( + '#type' => 'checkboxes', + '#options' => $properties, + '#default_value' => $default_properties, + '#title' => t('Managed Properties'), + '#description' => t('Select the properties you would like to be able to manage like fields through the "Manage Fields" and "Display Fields" tabs on this Bundle.'), + ); + // Let the behaviors to modify form. $vars = eck_property_behavior_invoke_plugin_alter($entity_type, 'bundle_form', array('form' => $form, 'form_state' => $form_state)); $form = $vars['form']; diff --git a/eck.module b/eck.module index 59c1130..f4dcf55 100644 --- a/eck.module +++ b/eck.module @@ -323,6 +323,34 @@ function eck_entity_info_alter(&$info) { } /** + * Implements hook_field_extra_fields(). + */ +function eck_field_extra_fields() { + $extra = array(); + + foreach(EntityType::loadAll() as $entity_type){ + foreach(Bundle::loadByEntityType($entity_type) as $bundle){ + foreach($entity_type->properties as $property_name => $property_info) { + if (!empty($bundle->config['managed_properties'][$property_name])) { + $extra[$entity_type->name][$bundle->name]['form'][$property_name] = array( + 'label' => $property_info['label'], + 'description' => t('Entity property'), + 'weight' => 0, + ); + + $extra[$entity_type->name][$bundle->name]['display'][$property_name] = array( + 'label' => $property_info['label'], + 'description' => t('Entity property'), + 'weight' => 0, + ); + } + } + } + } + return $extra; +} + +/** * Entity type load. */ function entity_type_load($entity_type_name) {