瀏覽代碼

Added a 'record type' field that gets added automatically to all entities. Fixed bugs in dbxref field

Stephen Ficklin 9 年之前
父節點
當前提交
64cf914a53

+ 47 - 40
tripal/api/tripal.entities.api.inc

@@ -183,6 +183,8 @@ function tripal_refresh_bundle_fields($bundle_name) {
   // Allow modules now add fields to the bundle
   module_invoke_all('add_bundle_fields', 'TripalEntity', $bundle, $term);
 }
+
+
 /**
  * Adds a field to an Entity bundle.
  *
@@ -218,54 +220,59 @@ function tripal_add_bundle_field($field_name, $field_info, $entity_type_name, $b
 
   $field = field_info_field($field_name);
 
+  // If the field is not present something is wrong and we should return.
+//   if (!$field) {
+//     tripal_report_error('tripal', TRIPAL_ERROR,
+//         "The field, '%name', cannot be found. Cannot add it to the bundle.",
+//         array('%name' => $field_name));
+//     return;
+//   }
+
   // If the field exists and is attached to this bundle then just return,
   // there is nothing left to do.
   if ($field and array_key_exists('bundles', $field) and
       array_key_exists($entity_type_name, $field['bundles']) and
       in_array($bundle_name, $field['bundles'][$entity_type_name])) {
-        return;
-      }
-
-      // Allow other modules to alter the field information array.
-      drupal_alter('chado_field', $field_info);
+    return;
+  }
 
-      $cardinality = 1;
-      if (array_key_exists('cardinality', $field_info) and is_numeric($field_info['cardinality'])) {
-        $cardinality = $field_info['cardinality'];
-      }
+  $cardinality = 1;
+  if (array_key_exists('cardinality', $field_info) and is_numeric($field_info['cardinality'])) {
+    $cardinality = $field_info['cardinality'];
+  }
 
-      // If the field doesn't exist then create it.
-      if (!$field) {
-        $field = array(
-          'field_name' => $field_name,
-          'type' => $field_info['field_type'],
-          'cardinality' => $cardinality,
-          'locked' => FALSE,
-          'storage' => array(
-            'type' => 'field_chado_storage'
-          ),
-          'settings' => $field_info['field_settings'],
-        );
-        field_create_field($field);
-      }
+  // If the field doesn't exist then create it.
+  if (!$field) {
+    $field = array(
+      'field_name' => $field_name,
+      'type' => $field_info['field_type'],
+      'cardinality' => $cardinality,
+      'locked' => FALSE,
+      'storage' => array(
+        'type' => $field_info['storage']
+      ),
+      'settings' => $field_info['field_settings'],
+    );
+    field_create_field($field);
+  }
 
-      // Attach the field to the bundle.
-      $field_instance = array(
-        'field_name' => $field_name,
-        'label' => $field_info['label'],
-        'description' => $field_info['description'],
-        'widget' => array(
-          'type' => $field_info['widget_type'],
-          'settings' => $field_info['widget_settings'],
-        ),
-        'entity_type' => $entity_type_name,
-        'required' => $field_info['is_required'],
-        'settings' => $field_info['field_settings'],
-        'bundle' => $bundle_name,
-        'default_value' => array_key_exists('default_value', $field_info) ? $field_info['default_value'] : '',
-        'format' => array_key_exists('format', $field_info) ? $field_info['format'] : '',
-      );
-      field_create_instance($field_instance);
+  // Attach the field to the bundle.
+  $field_instance = array(
+    'field_name' => $field_name,
+    'label' => $field_info['label'],
+    'description' => $field_info['description'],
+    'widget' => array(
+      'type' => $field_info['widget_type'],
+      'settings' => $field_info['widget_settings'],
+    ),
+    'entity_type' => $entity_type_name,
+    'required' => $field_info['is_required'],
+    'settings' => $field_info['field_settings'],
+    'bundle' => $bundle_name,
+    'default_value' => array_key_exists('default_value', $field_info) ? $field_info['default_value'] : '',
+    'format' => array_key_exists('format', $field_info) ? $field_info['format'] : '',
+  );
+  field_create_instance($field_instance);
 }
 /**
  * Allows a module to make changes to an entity object after creation.

+ 39 - 0
tripal/includes/fields/content_type.inc

@@ -0,0 +1,39 @@
+<?php
+/**
+ *
+ * @param $entity_type
+ * @param $entity
+ * @param $field
+ * @param $instance
+ * @param $langcode
+ * @param $items
+ * @param $display
+ */
+function tripal_content_type_formatter(&$element, $entity_type, $entity, $field,
+    $instance, $langcode, $items, $display) {
+
+  foreach ($items as $delta => $item) {
+    $element[$delta] = array(
+      '#type' => 'markup',
+      '#markup' => $item['value'],
+    );
+  }
+}
+
+/**
+ * Loads the field values with appropriate data.
+ *
+ * This function is called by the tripal_chado_field_storage_load() for
+ * each property managed by the field_chado_storage storage type.  This is
+ * an optional hook function that is only needed if the field has
+ * multiple form elements.
+ *
+ * @param $field
+ * @param $entity
+ */
+function tripal_content_type_field_load($field, $entity) {
+
+  $bundle = tripal_load_bundle_entity(array('name' => $entity->bundle));
+  $field_name = $field['field_name'];
+  $entity->{$field_name}['und'][0]['value'] = $bundle->label;
+}

+ 201 - 1
tripal/tripal.module

@@ -827,7 +827,7 @@ function tripal_menu_alter(&$items) {
  * Simple provides a message indicating that the field cannot be deleted.
  */
 function tripal_field_no_delete() {
-  drupal_set_message('This field is currently managed by the biological data store and cannot be removed.', 'warning');
+  drupal_set_message('This field cannot be removed.', 'warning');
   return '';
 }
 
@@ -853,4 +853,204 @@ function tripal_import_api() {
   module_load_include('inc', 'tripal', 'api/tripal.jobs.api');
   module_load_include('inc', 'tripal', 'api/tripal.notice.api');
   module_load_include('inc', 'tripal', 'api/tripal.variables.api');
+}
+
+/**
+ * Implements hook_field_storage_info().
+ *
+ * The Tripal module does not provide a storage back-end.  But it does provide
+ * a placeholder when no storage backend is needed but a field
+ * is still desired.  The 'tripal_no_storage' backend is used for the
+ * content_type field which adds a type field to every entity.
+ */
+function tripal_field_storage_info() {
+  return array(
+    'tripal_no_storage' => array(
+      'label' => t(''),
+      'description' => t('The NULL storage is a placeholder for field values
+          that are not stored in any storage backend (e.g. entity types).'),
+      'settings' => array(),
+    ),
+  );
+}
+/**
+ * Implements hook_field_info().
+ */
+function tripal_field_info() {
+  $fields = array(
+    'content_type' => array(
+      'label' => t('Record Type'),
+      'description' => t('The content type.'),
+      'default_widget' => 'tripal_content_type_widget',
+      'default_formatter' => 'tripal_content_type_formatter',
+      'settings' => array(),
+      'storage' => array(
+        'type' => 'tripal_no_storage',
+        'module' => 'tripal',
+        'active' => TRUE
+      ),
+    ),
+  );
+  return $fields;
+}
+/**
+ * Implements hook_field_widget_info();
+ */
+function tripal_field_widget_info() {
+  return array(
+    'tripal_content_type_widget' => array(
+      'label' => t('Record Type'),
+      'field types' => array('content_type')
+    ),
+  );
+}
+
+/**
+ * Implements hook_field_formatter_info().
+ */
+function tripal_field_formatter_info() {
+  return array(
+    'tripal_content_type_formatter' => array(
+      'label' => t('Record Type'),
+      'field types' => array('content_type')
+    ),
+  );
+}
+/**
+ * Implements hook_field_widget_form().
+ */
+function tripal_field_widget_form(&$form, &$form_state, $field,
+    $instance, $langcode, $items, $delta, $element) {
+
+  $widget = $element;
+  switch ($instance['widget']['type']) {
+    case 'tripal_content_type_widget':
+      // There is no widget for this type.
+      break;
+  }
+}
+/**
+ * Implements hook_field_formatter_view().
+ */
+function tripal_field_formatter_view($entity_type, $entity, $field,
+    $instance, $langcode, $items, $display) {
+
+  $element = array();
+  switch ($display['type']) {
+    case 'tripal_content_type_formatter':
+      module_load_include('inc', 'tripal', 'includes/fields/content_type');
+      tripal_content_type_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+  }
+  return $element;
+}
+
+/**
+ * Implemenation of hook_add_bundle_fields().
+ *
+ * In this function we add the type field.
+ */
+function tripal_add_bundle_fields($entity_type, $bundle, $term) {
+  $field_name = 'content_type';
+  $bundle_name = $bundle->name;
+
+  // Create the field array.
+  $field_info = array(
+    'field_type' => 'content_type',
+    'widget_type' => 'tripal_content_type_widget',
+    'widget_settings' => array('display_label' => 1),
+    'description' => '',
+    'label' => 'Record Type',
+    'is_required' => 0,
+    'storage' => 'tripal_no_storage',
+    'field_settings' => array(
+      'semantic_web' => array(
+        // The type is the term from a vocabulary that desribes this field..
+        'type' => '',
+        // The namepsace for the vocabulary (e.g. 'foaf').
+        'ns' => '',
+        // The URL for the namespace.  It must be that the type can be
+        // appended to the URL.
+        'nsurl' => '',
+      ),
+    ),
+  );
+
+  tripal_add_bundle_field($field_name, $field_info, $entity_type, $bundle_name);
+}
+
+/**
+ * Implements hook_field_storage_query().
+ *
+ * Used by EntityFieldQuery to find the entities having certain entity
+ * and field conditions and sort them in the given field order.
+ *
+ * NOTE: This function needs to exist or errors are triggered but so far it doesn't
+ * appear to actually need to do anything...
+ */
+function tripal_field_storage_query($query) { }
+
+/**
+ * Implements hook_field_storage_load().
+ *
+ * Responsible for loading the fields from the Chado database and adding
+ * their values to the entity.
+ */
+function tripal_field_storage_load($entity_type, $entities, $age,
+    $fields, $options) {
+
+  $load_current = $age == FIELD_LOAD_CURRENT;
+  global $language;
+  $langcode = $language->language;
+
+  foreach ($entities as $id => $entity) {
+
+    // Iterate through the entity's fields so we can get the column names
+    // that need to be selected from each of the tables represented.
+    $tables = array();
+    foreach ($fields as $field_id => $ids) {
+
+      // By the time this hook runs, the relevant field definitions have been
+      // populated and cached in FieldInfo, so calling field_info_field_by_id()
+      // on each field individually is more efficient than loading all fields in
+      // memory upfront with field_info_field_by_ids().
+      $field = field_info_field_by_id($field_id);
+      $field_name = $field['field_name'];
+      $field_type = $field['type'];
+      $field_module = $field['module'];
+
+      // Allow the creating module to alter the value if desired.  The
+      // module should do this if the field has any other form elements
+      // that need populationg besides the default value.
+      $load_function = $field_module . '_' . $field_type . '_field_load';
+      module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
+      if (function_exists($load_function)) {
+        $load_function($field, $entity);
+      }
+
+    } // end: foreach ($fields as $field_id => $ids) {
+  } // end: foreach ($entities as $id => $entity) {
+}
+
+/**
+ * Implements hook_field_is_empty().
+ */
+function tripal_field_is_empty($item, $field) {
+
+  // If there is no value field then the field is empty.
+  if (!array_key_exists('value', $item)) {
+    return TRUE;
+  }
+
+  // Iterate through all of the fields and if at least one has a value
+  // the field is not empty.
+  foreach ($item as $form_field_name => $value) {
+    if (isset($value) and $value != NULL and $value != '') {
+      return FALSE;
+    }
+  }
+
+  // Otherwise, the field is empty.
+  return TRUE;
 }

+ 0 - 1
tripal_chado/includes/fields/cvterm.inc

@@ -331,7 +331,6 @@ function tripal_chado_cvterm_field_load($field, $entity, $base_table, $record) {
   );
 
   $linker_table = $base_table . '_cvterm';
-  dpm($linker_table);
   /* $options = array('return_array' => 1);
   $record = chado_expand_var($record, 'table', $linker_table, $options);
   $i = 0;

+ 24 - 20
tripal_chado/includes/fields/dbxref.inc

@@ -56,7 +56,7 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
 
   // Get the field defaults.
   $record_id = '';
-  $fkey_value = $element['#entity']->chado_record_id;
+  $fkey_value = '';
   $dbxref_id = '';
   $db_id = '';
   $accession = '';
@@ -245,21 +245,23 @@ function tripal_chado_dbxref_widget_validate($element, &$form_state) {
     form_set_error(implode('][', $element ['#parents']) . '][' . $table_name . '--dbxref__db_id', t("A database and the accession must both be provided for the primary cross reference."));
   }
 
-  // If user did not select a database, we want to remove dbxref_id from the
-  // field.
-  if (!$db_id) {
-    tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__');
-  }
   // If the dbxref_id does not match the db_id + accession then the user
   // has selected a new dbxref record and we need to update the hidden
   // value accordingly.
   if ($db_id and $accession) {
+    $fkey_value = $element['#entity']->chado_record_id;
+    tripal_chado_set_field_form_values($field_name, $form_state, $fkey_value, $delta, $table_name . '__' . $fkey);
+
     $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
     if ($dbxref and $dbxref->dbxref_id != $dbxref_id) {
       tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, $delta, $table_name . '__dbxref_id');
       tripal_chado_set_field_form_values($field_name, $form_state, $dbxref->dbxref_id, $delta, $table_name . '--dbxref__dbxref_id');
     }
   }
+  else {
+    // If the db_id and accession are not set, then remove the linker FK value to the base table.
+    tripal_chado_set_field_form_values($field_name, $form_state, '', $delta, $table_name . '__' . $fkey);
+  }
 }
 /**
  * Theme function for the dbxref_id_widget.
@@ -332,20 +334,22 @@ function tripal_chado_dbxref_field_load($field, $entity, $base_table, $record) {
   $linker_table = $base_table . '_dbxref';
   $options = array('return_array' => 1);
   $record = chado_expand_var($record, 'table', $linker_table, $options);
-  $i = 0;
-  foreach ($record->$linker_table as $index => $linker) {
-    $dbxref = $linker->dbxref_id;
-    $entity->{$field_name}['und'][$i] = array(
-      'value' => $linker->$pkey,
-      $chado_table . '__' . $fkey => $linker->$fkey->$fkey,
-      $chado_table . '__' . 'dbxref_id' => $dbxref->dbxref_id,
-      $chado_table . '--' . 'dbxref__dbxref_id' => $dbxref->dbxref_id,
-      $chado_table . '--' . 'dbxref__db_id' => $dbxref->db_id->db_id,
-      $chado_table . '--' . 'dbxref__accession' => $dbxref->accession,
-      $chado_table . '--' . 'dbxref__version' => $dbxref->version,
-      $chado_table . '--' . 'dbxref__description' => $dbxref->description,
-    );
-    $i++;
+  if (count($record->$linker_table) > 0) {
+    $i = 0;
+    foreach ($record->$linker_table as $index => $linker) {
+      $dbxref = $linker->dbxref_id;
+      $entity->{$field_name}['und'][$i] = array(
+        'value' => $linker->$pkey,
+        $chado_table . '__' . $fkey => $linker->$fkey->$fkey,
+        $chado_table . '__' . 'dbxref_id' => $dbxref->dbxref_id,
+        $chado_table . '--' . 'dbxref__dbxref_id' => $dbxref->dbxref_id,
+        $chado_table . '--' . 'dbxref__db_id' => $dbxref->db_id->db_id,
+        $chado_table . '--' . 'dbxref__accession' => $dbxref->accession,
+        $chado_table . '--' . 'dbxref__version' => $dbxref->version,
+        $chado_table . '--' . 'dbxref__description' => $dbxref->description,
+      );
+      $i++;
+    }
   }
 }
 

+ 1 - 0
tripal_chado/includes/fields/kvproperty_adder.inc

@@ -98,6 +98,7 @@ function tripal_chado_kvproperty_adder_widget_validate($element, &$form_state) {
            'chado_column' => $pkey,
            'base_table' => $base_table,
          ),
+         'storage' => 'field_chado_storage',
          'widget_settings' => array(),
          'description' => $term[0]->definition ? $term[0]->definition : '',
          'label' => ucfirst(preg_replace('/_/', ' ', $term[0]->name)),

+ 1 - 2
tripal_chado/includes/fields/organism_id.inc

@@ -13,6 +13,7 @@
  */
 function tripal_chado_organism_select_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
+
   foreach ($items as $delta => $item) {
     $organism = chado_select_record('organism', array('genus', 'species'), array('organism_id' => $item['value']));
     $content = '<i>' . $organism[0]->genus .' ' . $organism[0]->species . '</i>';
@@ -75,7 +76,6 @@ function tripal_chado_organism_select_widget_validate($element, &$form_state) {
 function organism_id_field_formatter_settings_summary($field, $instance, $view_mode) {
   $display = $instance['display'][$view_mode];
   $settings = $display['settings'];
-  dpm('yo');
 
   $summary = '';
 
@@ -97,7 +97,6 @@ function organism_id_field_formatter_settings_summary($field, $instance, $view_m
 function organism_id_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
   $display = $instance['display'][$view_mode];
   $settings = $display['settings'];
-  dpm('hi');
   $element = array();
 
   if ($display['type'] == 'text_trimmed' || $display['type'] == 'text_summary_or_trimmed') {

+ 1 - 0
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -194,6 +194,7 @@ function tripal_chado_field_storage_write_recursive($entity_type, $entity, $term
       $values[$chado_field] = $items[0]['value'];
     }
   }
+
   // STEP 3: Insert/Update the record.
   // If there are no values then return.
   if (count($values) == 0) {

+ 0 - 1
tripal_chado/includes/tripal_chado.publish.inc

@@ -65,7 +65,6 @@ function tripal_chado_publish_form($form, &$form_state) {
       }
       // None of the fields should be required.
 
-      dpm($form['filters'][$field_name]);
     } */
 
     $form['publish_btn'] = array(

+ 55 - 81
tripal_chado/tripal_chado.module

@@ -628,36 +628,6 @@ function tripal_chado_field_formatter_info() {
   );
 }
 
-/**
- * Implements hook_chado_field_alter().
- *
- * This function is used to change the default field formatter and widget
- * that are assigned to fields of an Entity. This hook is only used for
- * those fields that correspond to a column in a Chado table.  An implementation
- * of this hook can be used to change the default formatters and widgets to
- * custom formatters and widgets that are created by the module creating
- * this hook.
- *
- * By default, Tripal will provide custom formatters and widgets for many
- * columns in Chado tables, therefore, this hook will most likely be of use
- * to extension modules that create custom table inside of Chado.
- *
- * @param $field
- */
-function hook_chado_field_alter(&$field) {
-
-  if (!array_key_exists('field_settings', $field)) {
-    return;
-  }
-  // If the field doesn't list the Chado table or column then just return.
-  if (!array_key_exists('chado_table', $field['field_settings']) or
-      !array_key_exists('chado_column', $field['field_settings'])) {
-    return;
-  }
-  // Here we provide new field types and widgets for FK fields
-  // and fields that need special attention.
-}
-
 /**
  * Implements hook_field_widget_form_alter().
  */
@@ -695,57 +665,57 @@ function tripal_chado_field_widget_form_alter(&$element, &$form_state, $context)
  * Implements hook_field_formatter_view().
  */
 function tripal_chado_field_formatter_view($entity_type, $entity, $field,
-    $instance, $langcode, $items, $display) {
-
-      $element = array();
-      switch ($display['type']) {
-        case 'tripal_chado_organism_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/organism_id');
-          tripal_chado_organism_select_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_dbxref_id_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref_id');
-          tripal_chado_dbxref_id_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_dbxref_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref');
-          tripal_chado_dbxref_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_cvterm_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/cvterm');
-          tripal_chado_cvterm_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_md5checksum_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/md5checksum');
-          tripal_chado_md5checksum_checkbox_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_residues_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/residues');
-          tripal_chado_residues_textarea_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_seqlen_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/seqlen');
-          tripal_chado_seqlen_hidden_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_kvproperty_adder_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty_adder');
-          tripal_chado_kvproperty_adder_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-        case 'tripal_chado_kvproperty_formatter':
-          module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty');
-          tripal_chado_kvproperty_formatter($element, $entity_type, $entity, $field,
-              $instance, $langcode, $items, $display);
-          break;
-      }
-      return $element;
+  $instance, $langcode, $items, $display) {
+
+  $element = array();
+  switch ($display['type']) {
+    case 'tripal_chado_organism_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/organism_id');
+      tripal_chado_organism_select_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_dbxref_id_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref_id');
+      tripal_chado_dbxref_id_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_dbxref_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref');
+      tripal_chado_dbxref_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_cvterm_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/cvterm');
+      tripal_chado_cvterm_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_md5checksum_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/md5checksum');
+      tripal_chado_md5checksum_checkbox_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_residues_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/residues');
+      tripal_chado_residues_textarea_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_seqlen_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/seqlen');
+      tripal_chado_seqlen_hidden_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_kvproperty_adder_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty_adder');
+      tripal_chado_kvproperty_adder_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+    case 'tripal_chado_kvproperty_formatter':
+      module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty');
+      tripal_chado_kvproperty_formatter($element, $entity_type, $entity, $field,
+          $instance, $langcode, $items, $display);
+      break;
+  }
+  return $element;
 }
 
 /**
@@ -1098,6 +1068,7 @@ function tripal_chado_add_bundle_dbxref_field($entity_type_name, $bundle_name, $
     'label' => 'Cross References',
     'is_required' => 0,
     'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+    'storage' => 'field_chado_storage',
     'field_settings' => array(
       // The Chado table that this field maps to.
       'chado_table' => $dbxref_table,
@@ -1149,6 +1120,7 @@ function tripal_chado_add_bundle_cvterm_field($entity_type_name, $bundle_name, $
     'label' => 'Annotations',
     'is_required' => 0,
     'cardinality' => FIELD_CARDINALITY_UNLIMITED,
+    'storage' => 'field_chado_storage',
     'field_settings' => array(
       // The Chado table that this field maps to.
       'chado_table' => $cvterm_table,
@@ -1188,6 +1160,7 @@ function tripal_chado_add_bundle_kvproperty_adder_field($entity_type_name, $bund
     'field_settings' => array(
       'base_table' => $base_table,
     ),
+    'storage' => 'field_chado_storage',
     'widget_settings' => array('display_label' => 1),
     'description' => '',
     'label' => 'Additional Properties',
@@ -1274,6 +1247,7 @@ function tripal_chado_get_table_column_field_default($table_name, $schema, $colu
     'description' => '',
     'label' => ucwords(preg_replace('/_/', ' ', $column_name)),
     'is_required' => 0,
+    'storage' => 'field_chado_storage',
     'widget_settings' => array(
       'display_label' => 1
     ),

+ 3 - 4
tripal_panes/tripal_panes.module

@@ -136,7 +136,6 @@ function tripal_panes_form_field_ui_display_overview_form_alter(&$form, &$form_s
   $submit = $form['#submit'];
   $form['#submit'] = array('tripal_panes_field_ui_submit');
   $form['#submit'] = array_merge($form['#submit'], $submit);
-  //dpm($form);
 }
 
 /**
@@ -333,7 +332,7 @@ function tripal_panes_form_field_ui_display_overview_form_pane_configure (&$form
         '#type' => 'hidden',
         '#value' => $field->field_id,
       );
-      $default_classes = 
+      $default_classes =
         db_select('tripal_pane_fields', 'tpf')
           ->fields('tpf', array('css_class'))
           ->condition('pane_id', $pane->pane_id)
@@ -739,7 +738,7 @@ function tripal_panes_action_configure_panes (&$form, &$form_state) {
         if ($value['table_group'] == 1) {
           $table_layout[] = $key;
         }
-      } 
+      }
       // Save CSS class for each field if provided
       if (is_array($value) && key_exists('css_class', $value) && $value['css_class']) {
         db_update('tripal_pane_fields')
@@ -898,7 +897,7 @@ function tripal_panes_entity_view($entity, $type, $view_mode, $langcode) {
           if ($pane_id != $disabled_pane_id) {
             // Construct field elements
             $fields[$pane_id][$field_name] = $entity->content[$field_name];
-            
+
             // Add extra css classes
             $css_class = db_select('tripal_pane_fields', 'tpf')
               ->fields('tpf', array('css_class'))