Browse Source

Renamed all fields to have a consitent naming. Adjusted form for adding new content types to help ensure the wrong term isn't used for creating an entity

Stephen Ficklin 10 năm trước cách đây
mục cha
commit
6ac6e2d8fa

+ 4 - 0
tripal/api/tripal.entities.api.inc

@@ -469,6 +469,10 @@ function tripal_set_bundle_variable($variable_name, $bundle_id, $value) {
 
   $variable = tripal_get_variable($variable_name);
 
+  if (!$variable) {
+    return FALSE;
+  }
+
   // And then we need to write the new format to the tripal_bundle_variables table.
   $record = array(
     'bundle_id' => $bundle_id,

+ 39 - 8
tripal/includes/TripalBundleUIController.inc

@@ -98,15 +98,46 @@ function tripal_tripal_bundle_form($form, &$form_state, $entityDataType) {
   );
 
   if ($term) {
+
+    $rows = array(
+      array(
+        array(
+          'header' => TRUE,
+          'data' => 'Vocabulary',
+          'class' => array('side-header')
+        ),
+        $vocab->namespace
+      ),
+      array(
+        array(
+          'header' => TRUE,
+          'data' => 'Term',
+          'class' => array('side-header')
+        ),
+        $term->name
+      ),
+      array(
+        array(
+          'header' => TRUE,
+          'data' => 'Definition',
+          'class' => array('side-header')
+        ),
+        $term->definition
+      )
+    );
+    $table_vars = array(
+      'header' => array(),
+      'rows' => $rows,
+      'attributes' => array(),
+      'caption' => '',
+      'sticky' => FALSE,
+      'colgroups' => array(),
+      'empty' => '',
+    );
     $form['term'] = array(
-      '#type' => 'markup',
-      '#markup' => theme('table', array(
-        'header' => array(),
-        'rows' => array(
-          array(array('header' => TRUE, 'data' => 'Vocabulary', 'class' => array('side-header')), $vocab->namespace),
-          array(array('header' => TRUE, 'data' => 'Term', 'class' => array('side-header')), $term->name),
-        )
-      ))
+      '#type' => 'item',
+      '#title' => t('Vocabulary Term'),
+      '#markup' => theme_table($table_vars)
     );
   }
 

+ 10 - 10
tripal_chado/includes/fields/base__dbxref_id.inc → tripal_chado/includes/fields/chado_base__dbxref_id.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_dbxref_id_formatter(&$element, $entity_type, $entity, $field,
+function chado_base__dbxref_id_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -42,7 +42,7 @@ function tripal_chado_dbxref_id_formatter(&$element, $entity_type, $entity, $fie
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_dbxref_id_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_base__dbxref_id_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $field_name = $field['field_name'];
 
   // Get the field defaults.
@@ -86,8 +86,8 @@ function tripal_chado_dbxref_id_widget(&$widget, $form, $form_state, $field, $in
   $schema = chado_get_schema('dbxref');
   $options = tripal_get_db_select_options();
 
-  $widget['#element_validate'] = array('tripal_chado_dbxref_id_widget_validate');
-  $widget['#theme'] = 'tripal_chado_dbxref_id_widget';
+  $widget['#element_validate'] = array('chado_base__dbxref_id_widget_validate');
+  $widget['#theme'] = 'chado_base__dbxref_id_widget';
   $widget['#prefix'] =  "<span id='$field_name-dbxref--db-id'>";
   $widget['#suffix'] =  "</span>";
 
@@ -96,7 +96,7 @@ function tripal_chado_dbxref_id_widget(&$widget, $form, $form_state, $field, $in
     '#title' => $element['#title'],
     '#description' =>  $element['#description'],
     '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
-    '#theme' => 'tripal_chado_dbxref_id_widget',
+    '#theme' => 'chado_base__dbxref_id_widget',
     //'#collapsible' => TRUE,
     //'#collapsed' => $collapsed,
   );
@@ -113,7 +113,7 @@ function tripal_chado_dbxref_id_widget(&$widget, $form, $form_state, $field, $in
     '#required' => $element['#required'],
     '#default_value' => $db_id,
     '#ajax' => array(
-      'callback' => "tripal_chado_dbxref_id_widget_form_ajax_callback",
+      'callback' => "chado_base__dbxref_id_widget_form_ajax_callback",
       'wrapper' => "$field_name-dbxref--db-id",
       'effect' => 'fade',
       'method' => 'replace'
@@ -158,7 +158,7 @@ function tripal_chado_dbxref_id_widget(&$widget, $form, $form_state, $field, $in
 /**
  * An Ajax callback for the tripal_chado_admin_publish_form..
  */
-function tripal_chado_dbxref_id_widget_form_ajax_callback($form, $form_state) {
+function chado_base__dbxref_id_widget_form_ajax_callback($form, $form_state) {
   $field_name = $form_state['triggering_element']['#parents'][0];
   $db_id = tripal_chado_get_field_form_values($field_name, $form_state, 0, 'dbxref__db_id');
   $accession = tripal_chado_get_field_form_values($field_name, $form_state, 0, 'dbxref__accession');
@@ -180,7 +180,7 @@ function tripal_chado_dbxref_id_widget_form_ajax_callback($form, $form_state) {
 /**
  * Callback function for validating the tripal_chado_organism_select_widget.
  */
-function tripal_chado_dbxref_id_widget_validate($element, &$form_state) {
+function chado_base__dbxref_id_widget_validate($element, &$form_state) {
   $field_name = $element['#parents'][0];
 
   // If the form ID is field_ui_field_edit_form, then the user is editing the
@@ -234,7 +234,7 @@ function tripal_chado_dbxref_id_widget_validate($element, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_chado_dbxref_id_widget($variables) {
+function theme_chado_base__dbxref_id_widget($variables) {
   $element = $variables['element'];
 
   $layout = "
@@ -285,7 +285,7 @@ function theme_tripal_chado_dbxref_id_widget($variables) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_dbxref_id_field_load($field, $entity, $base_table, $record) {
+function chado_base__dbxref_id_field_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 6 - 6
tripal_chado/includes/fields/base__organism_id.inc → tripal_chado/includes/fields/chado_base__organism_id.inc

@@ -11,7 +11,7 @@
  * @param $display
  * @return string
  */
-function tripal_chado_organism_select_formatter(&$element, $entity_type, $entity, $field,
+function chado_base__organism_id_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -36,7 +36,7 @@ function tripal_chado_organism_select_formatter(&$element, $entity_type, $entity
  * @param $delta
  * @param $element
  */
-function tripal_chado_organism_select_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_base__organism_id_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $options = tripal_get_organism_select_options(FALSE);
   $widget['value'] = array(
     '#type' => 'select',
@@ -47,7 +47,7 @@ function tripal_chado_organism_select_widget(&$widget, $form, $form_state, $fiel
     '#required' => $element['#required'],
     '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
     '#delta' => $delta,
-    '#element_validate' => array('tripal_chado_organism_select_widget_validate'),
+    '#element_validate' => array('chado_base__organism_id_widget_validate'),
   );
   $widget['add_organism'] = array(
     '#type' => 'item',
@@ -55,9 +55,9 @@ function tripal_chado_organism_select_widget(&$widget, $form, $form_state, $fiel
   );
 }
 /**
- * Callback function for validating the tripal_chado_organism_select_widget.
+ * Callback function for validating the chado_base__organism_id_widget.
  */
-function tripal_chado_organism_select_widget_validate($element, &$form_state) {
+function chado_base__organism_id_widget_validate($element, &$form_state) {
   $field_name = $element['#parents'][0];
 
   // If the form ID is field_ui_field_edit_form, then the user is editing the
@@ -90,7 +90,7 @@ function tripal_chado_organism_select_widget_validate($element, &$form_state) {
  * @param $form_state
  *   The form state of the (entire) configuration form.
  */
-function tripal_chado_organism_select_formatter_form($field, $instance,
+function chado_base__organism_id_formatter_form($field, $instance,
     $view_mode, $form, &$form_state) {
 
   $display = $instance['display'][$view_mode];

+ 6 - 6
tripal_chado/includes/fields/feature__md5checksum.inc → tripal_chado/includes/fields/chado_feature__md5checksum.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_md5checksum_checkbox_formatter(&$element, $entity_type, $entity, $field,
+function chado_feature__md5checksum_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
   foreach ($items as $delta => $item) {
     $content = key_exists('value', $item) ? $item['value'] : '';
@@ -34,7 +34,7 @@ function tripal_chado_md5checksum_checkbox_formatter(&$element, $entity_type, $e
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_md5checksum_checkbox_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_feature__md5checksum_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
 
   $widget['value'] = array(
     '#type' => 'checkbox',
@@ -44,13 +44,13 @@ function tripal_chado_md5checksum_checkbox_widget(&$widget, $form, $form_state,
     '#default_value' => 1,
     '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
     '#delta' => $delta,
-    '#element_validate' => array('tripal_chado_md5checksum_checkbox_widget_validate'),
+    '#element_validate' => array('chado_feature__md5checksum_widget_validate'),
   );
 }
 /**
- * Callback function for validating the tripal_chado_md5checksum_checkbox_widget.
+ * Callback function for validating the chado_feature__md5checksum_widget.
  */
-function tripal_chado_md5checksum_checkbox_widget_validate($element, &$form_state) {
+function chado_feature__md5checksum_widget_validate($element, &$form_state) {
   $field_name = $element['#parents'][0];
 
   // Calculate the md5 checksum for the sequence only if md5 box is checked and
@@ -76,7 +76,7 @@ function tripal_chado_md5checksum_checkbox_widget_validate($element, &$form_stat
  * @param $entity
  * @param $record
  */
-function tripal_chado_md5checksum_field_load($field, $entity, $record) {
+function chado_feature__md5checksum_field_load($field, $entity, $record) {
   $field_name = $field['field_name'];
   if ($record and property_exists($record, 'md5checksum')) {
     $entity->{$field_name}['und'][] = array('value' => $record->md5checksum);

+ 5 - 5
tripal_chado/includes/fields/feature__residues.inc → tripal_chado/includes/fields/chado_feature__residues.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_residues_textarea_formatter(&$element, $entity_type, $entity, $field,
+function chado_feature__residues_formatter(&$element, $entity_type, $entity, $field,
   $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -37,7 +37,7 @@ function tripal_chado_residues_textarea_formatter(&$element, $entity_type, $enti
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_residues_textarea_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_feature__residues_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
 
   $widget['value'] = array(
     '#type' => 'textarea',
@@ -46,14 +46,14 @@ function tripal_chado_residues_textarea_widget(&$widget, $form, $form_state, $fi
     '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
     '#default_value' => count($items) > 0 ? $items[0]['value'] : '',
     '#delta' => $delta,
-    '#element_validate' => array('tripal_chado_residues_textarea_widget_validate'),
+    '#element_validate' => array('chado_feature__residues_widget_validate'),
     '#cols' => 30,
   );
 }
 /**
- * Callback function for validating the tripal_chado_residues_textarea_widget.
+ * Callback function for validating the chado_feature__residues_widget.
  */
-function tripal_chado_residues_textarea_widget_validate($element, &$form_state) {
+function chado_feature__residues_widget_validate($element, &$form_state) {
   $field_name = $element['#parents'][0];
 
   // Remove any white spaces.

+ 5 - 5
tripal_chado/includes/fields/feature__seqlen.inc → tripal_chado/includes/fields/chado_feature__seqlen.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_seqlen_hidden_formatter(&$element, $entity_type, $entity, $field,
+function chado_feature__seqlen_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -36,7 +36,7 @@ function tripal_chado_seqlen_hidden_formatter(&$element, $entity_type, $entity,
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_seqlen_hidden_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_feature__seqlen_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
 
   $widget['value'] =  array(
     '#type' => 'hidden',
@@ -44,13 +44,13 @@ function tripal_chado_seqlen_hidden_widget(&$widget, $form, $form_state, $field,
     '#description' => $element['#description'],
     '#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
     '#delta' => $delta,
-    '#element_validate' => array('tripal_chado_seqlen_hidden_widget_validate'),
+    '#element_validate' => array('chado_feature__seqlen_widget_validate'),
   );
 }
 /**
- * Callback function for validating the tripal_chado_seqlen_hidden_widget.
+ * Callback function for validating the chado_feature__seqlen_widget.
  */
-function tripal_chado_seqlen_hidden_widget_validate($element, &$form_state) {
+function chado_feature__seqlen_widget_validate($element, &$form_state) {
   $field_name = $element['#parents'][0];
 
   // Get the residues so we can calculate teh length.

+ 9 - 9
tripal_chado/includes/fields/linker_cvterm.inc → tripal_chado/includes/fields/chado_linker__cvterm.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_cvterm_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__cvterm_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   $headers = array('Term', 'Definition', 'Is Not', 'Reference');
@@ -79,7 +79,7 @@ function tripal_chado_cvterm_formatter(&$element, $entity_type, $entity, $field,
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_cvterm_widget(&$widget, $form, $form_state, $field,
+function chado_linker__cvterm_widget(&$widget, $form, $form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
 
   $entity = $form['#entity'];
@@ -138,8 +138,8 @@ function tripal_chado_cvterm_widget(&$widget, $form, $form_state, $field,
 
   $widget['#table_name'] = $chado_table;
   $widget['#fkey_field'] = $fkey;
-  $widget['#element_validate'] = array('tripal_chado_cvterm_widget_validate');
-  $widget['#theme'] = 'tripal_chado_cvterm_widget';
+  $widget['#element_validate'] = array('chado_linker__cvterm_widget_validate');
+  $widget['#theme'] = 'chado_linker__cvterm_widget';
   $widget['#prefix'] =  "<span id='$table_name-$delta'>";
   $widget['#suffix'] =  "</span>";
 
@@ -168,7 +168,7 @@ function tripal_chado_cvterm_widget(&$widget, $form, $form_state, $field,
     '#maxlength' => array_key_exists('length', $schema['fields']['name']) ? $schema['fields']['name']['length'] : 255,
     '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/cvterm/' . $cv_id,
     '#ajax' => array(
-      'callback' => "tripal_chado_cvterm_widget_form_ajax_callback",
+      'callback' => "chado_linker__cvterm_widget_form_ajax_callback",
       'wrapper' => "$table_name-$delta",
       'effect' => 'fade',
       'method' => 'replace'
@@ -191,7 +191,7 @@ function tripal_chado_cvterm_widget(&$widget, $form, $form_state, $field,
 /**
  * An Ajax callback for the dbxref widget.
  */
-function tripal_chado_cvterm_widget_form_ajax_callback($form, $form_state) {
+function chado_linker__cvterm_widget_form_ajax_callback($form, $form_state) {
 
   $field_name = $form_state['triggering_element']['#parents'][0];
   $delta = $form_state['triggering_element']['#parents'][2];
@@ -203,7 +203,7 @@ function tripal_chado_cvterm_widget_form_ajax_callback($form, $form_state) {
 /**
  * Callback function for validating the tripal_chado_organism_select_widget.
  */
-function tripal_chado_cvterm_widget_validate($element, &$form_state) {
+function chado_linker__cvterm_widget_validate($element, &$form_state) {
 
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
@@ -254,7 +254,7 @@ function tripal_chado_cvterm_widget_validate($element, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_chado_cvterm_widget($variables) {
+function theme_chado_linker__cvterm_widget($variables) {
   $element = $variables['element'];
 
   // These two fields were added to the widget to help identify the fields
@@ -292,7 +292,7 @@ function theme_tripal_chado_cvterm_widget($variables) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_cvterm_field_load($field, $entity, $base_table, $record) {
+function chado_linker__cvterm_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 8 - 8
tripal_chado/includes/fields/linker_cvterm_adder.inc → tripal_chado/includes/fields/chado_linker__cvterm_adder.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_cvterm_class_adder_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__cvterm_adder_formatter(&$element, $entity_type, $entity, $field,
   $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -20,12 +20,12 @@ function tripal_chado_cvterm_class_adder_formatter(&$element, $entity_type, $ent
 /**
  *
  */
-function tripal_chado_cvterm_class_adder_widget(&$widget, &$form, &$form_state,
+function chado_linker__cvterm_adder_widget(&$widget, &$form, &$form_state,
     $field, $instance, $langcode, $items, $delta, $element) {
 
   // This field has no value field.  Just a fieldset for adding new annotation types.
 
-  $widget['#element_validate'] = array('tripal_chado_cvterm_class_adder_widget_validate');
+  $widget['#element_validate'] = array('chado_linker__cvterm_adder_widget_validate');
 
   $widget['#type'] = 'fieldset';
   $widget['#title'] = $element['#title'];
@@ -62,14 +62,14 @@ function tripal_chado_cvterm_class_adder_widget(&$widget, &$form, &$form_state,
     '#value' => t('Add Annotation Type'),
     '#type' => 'submit',
     '#name' => 'cvterm_class_adder_button',
-    '#submit' => array('tripal_chado_cvterm_class_adder_widget_submit'),
+    '#submit' => array('chado_linker__cvterm_adder_widget_submit'),
     '#limit_validation_errors' => array(array($field['field_name'])),
   );
 }
 /**
- * Callback function for validating the tripal_chado_cvterm_class_adder_widget.
+ * Callback function for validating the chado_linker__cvterm_adder_widget.
  */
-function tripal_chado_cvterm_class_adder_widget_validate($element, &$form_state) {
+function chado_linker__cvterm_adder_widget_validate($element, &$form_state) {
 
    // Add the new field to the entity
    if (array_key_exists('triggering_element', $form_state) and
@@ -121,8 +121,8 @@ function tripal_chado_cvterm_class_adder_widget_validate($element, &$form_state)
    }
 }
 /**
- * Callback function for submitting the tripal_chado_cvterm_class_adder_widget.
+ * Callback function for submitting the chado_linker__cvterm_adder_widget.
  */
-function tripal_chado_cvterm_class_adder_widget_submit($element, &$form_state) {
+function chado_linker__cvterm_adder_widget_submit($element, &$form_state) {
 
 }

+ 10 - 10
tripal_chado/includes/fields/linker_dbxref.inc → tripal_chado/includes/fields/chado_linker__dbxref.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_dbxref_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__dbxref_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   $chado_table = $field['settings']['chado_table'];
@@ -42,7 +42,7 @@ function tripal_chado_dbxref_formatter(&$element, $entity_type, $entity, $field,
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
+function chado_linker__dbxref_widget(&$widget, $form, $form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
 
   $field_name = $field['field_name'];
@@ -92,8 +92,8 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
 
   $widget['#table_name'] = $chado_table;
   $widget['#fkey_field'] = $fkey;
-  $widget['#element_validate'] = array('tripal_chado_dbxref_widget_validate');
-  $widget['#theme'] = 'tripal_chado_dbxref_widget';
+  $widget['#element_validate'] = array('chado_linker__dbxref_widget_validate');
+  $widget['#theme'] = 'chado_linker__dbxref_widget';
   $widget['#prefix'] =  "<span id='$field_name-dbxref--db-id-$delta'>";
   $widget['#suffix'] =  "</span>";
 
@@ -120,7 +120,7 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
     '#required' => $element['#required'],
     '#default_value' => $db_id,
     '#ajax' => array(
-      'callback' => "tripal_chado_dbxref_widget_form_ajax_callback",
+      'callback' => "chado_linker__dbxref_widget_form_ajax_callback",
       'wrapper' => "$field_name-dbxref--db-id-$delta",
       'effect' => 'fade',
       'method' => 'replace'
@@ -135,7 +135,7 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
     '#size' => 15,
     '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/dbxref/' . $db_id,
     '#ajax' => array(
-      'callback' => "tripal_chado_dbxref_widget_form_ajax_callback",
+      'callback' => "chado_linker__dbxref_widget_form_ajax_callback",
       'wrapper' => "$field_name-dbxref--db-id-$delta",
       'effect' => 'fade',
       'method' => 'replace'
@@ -167,7 +167,7 @@ function tripal_chado_dbxref_widget(&$widget, $form, $form_state, $field,
 /**
  * An Ajax callback for the dbxref widget.
  */
-function tripal_chado_dbxref_widget_form_ajax_callback($form, $form_state) {
+function chado_linker__dbxref_widget_form_ajax_callback($form, $form_state) {
 
   $field_name = $form_state['triggering_element']['#parents'][0];
   $delta = $form_state['triggering_element']['#parents'][2];
@@ -194,7 +194,7 @@ function tripal_chado_dbxref_widget_form_ajax_callback($form, $form_state) {
 /**
  * Callback function for validating the tripal_chado_organism_select_widget.
  */
-function tripal_chado_dbxref_widget_validate($element, &$form_state) {
+function chado_linker__dbxref_widget_validate($element, &$form_state) {
 
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
@@ -256,7 +256,7 @@ function tripal_chado_dbxref_widget_validate($element, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_chado_dbxref_widget($variables) {
+function theme_chado_linker__dbxref_widget($variables) {
   $element = $variables['element'];
 
   // These two fields were added to the widget to help identify the fields
@@ -298,7 +298,7 @@ function theme_tripal_chado_dbxref_widget($variables) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_dbxref_field_load($field, $entity, $base_table, $record) {
+function chado_linker__dbxref_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 9 - 9
tripal_chado/includes/fields/linker_prop.inc → tripal_chado/includes/fields/chado_linker__prop.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_kvproperty_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__prop_formatter(&$element, $entity_type, $entity, $field,
   $instance, $langcode, $items, $display) {
 
   $field_name = $field['field_name'];
@@ -39,7 +39,7 @@ function tripal_chado_kvproperty_formatter(&$element, $entity_type, $entity, $fi
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_kvproperty_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
+function chado_linker__prop_widget(&$widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $entity = $form['#entity'];
   $field_name = $field['field_name'];
 
@@ -84,7 +84,7 @@ function tripal_chado_kvproperty_widget(&$widget, $form, $form_state, $field, $i
   $widget['#field_name'] = $element['#field_name'];
   $widget['#language'] = $element['#language'];
   $widget['#weight'] = isset($element['#weight']) ? $element['#weight'] : 0;
-  $widget['#element_validate'] = array('tripal_chado_kvproperty_widget_validate');
+  $widget['#element_validate'] = array('chado_linker__prop_widget_validate');
   $widget['#cardinality'] = 1;
 
   $widget['value'] = array(
@@ -115,14 +115,14 @@ function tripal_chado_kvproperty_widget(&$widget, $form, $form_state, $field, $i
  * @param unknown $form
  * @param unknown $form_state
  */
-function tripal_chado_kvproperty_widget_form_ajax_callback($form, $form_state) {
+function chado_linker__prop_widget_form_ajax_callback($form, $form_state) {
   $field_name = $form_state['triggering_element']['#parents'][0];
   return $form[$field_name];
 }
 /**
- * Callback function for validating the tripal_chado_kvproperty_widget.
+ * Callback function for validating the chado_linker__prop_widget.
  */
-function tripal_chado_kvproperty_widget_validate($element, &$form_state) {
+function chado_linker__prop_widget_validate($element, &$form_state) {
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
   $entity = $element['#entity'];
@@ -172,9 +172,9 @@ function tripal_chado_kvproperty_widget_validate($element, &$form_state) {
   }
 }
 /**
- * Callback function for submitting the tripal_chado_kvproperty_widget.
+ * Callback function for submitting the chado_linker__prop_widget.
  */
-function tripal_chado_kvproperty_widget_submit($element, &$form_state) {
+function chado_linker__prop_widget_submit($element, &$form_state) {
 }
 
 /**
@@ -190,7 +190,7 @@ function tripal_chado_kvproperty_widget_submit($element, &$form_state) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_kvproperty_field_load($field, $entity, $base_table, $record) {
+function chado_linker__prop_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 8 - 8
tripal_chado/includes/fields/linker_prop_adder.inc → tripal_chado/includes/fields/chado_linker__prop_adder.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_kvproperty_adder_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__prop_adder_formatter(&$element, $entity_type, $entity, $field,
   $instance, $langcode, $items, $display) {
 
   foreach ($items as $delta => $item) {
@@ -20,10 +20,10 @@ function tripal_chado_kvproperty_adder_formatter(&$element, $entity_type, $entit
 /**
  *
  */
-function tripal_chado_kvproperty_adder_widget(&$widget, $form, $form_state,
+function chado_linker__prop_adder_widget(&$widget, $form, $form_state,
     $field, $instance, $langcode, $items, $delta, $element) {
   // This field has no value field.  Just a fieldset for adding new properties.
-  $widget['#element_validate'] = array('tripal_chado_kvproperty_adder_widget_validate');
+  $widget['#element_validate'] = array('chado_linker__prop_adder_widget_validate');
 
   $widget['#type'] = 'fieldset';
   $widget['#title'] = $element['#title'];
@@ -61,14 +61,14 @@ function tripal_chado_kvproperty_adder_widget(&$widget, $form, $form_state,
     '#value' => t('Add Property'),
     '#type' => 'submit',
     '#name' => 'kvproperty_adder_button',
-    '#submit' => array('tripal_chado_kvproperty_adder_widget_submit'),
+    '#submit' => array('chado_linker__prop_adder_widget_submit'),
     '#limit_validation_errors' => array(array($field['field_name'])),
   );
 }
 /**
- * Callback function for validating the tripal_chado_kvproperty_adder_widget.
+ * Callback function for validating the chado_linker__prop_adder_widget.
  */
-function tripal_chado_kvproperty_adder_widget_validate($element, &$form_state) {
+function chado_linker__prop_adder_widget_validate($element, &$form_state) {
 
    // Add the new field to the entity
    if (array_key_exists('triggering_element', $form_state) and
@@ -122,7 +122,7 @@ function tripal_chado_kvproperty_adder_widget_validate($element, &$form_state) {
    }
 }
 /**
- * Callback function for submitting the tripal_chado_kvproperty_adder_widget.
+ * Callback function for submitting the chado_linker__prop_adder_widget.
  */
-function tripal_chado_kvproperty_adder_widget_submit($element, &$form_state) {
+function chado_linker__prop_adder_widget_submit($element, &$form_state) {
 }

+ 9 - 9
tripal_chado/includes/fields/base__pub_id.inc → tripal_chado/includes/fields/chado_linker__pub.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_pub_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__pub_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   $list_items = array();
@@ -48,7 +48,7 @@ function tripal_chado_pub_formatter(&$element, $entity_type, $entity, $field,
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_pub_widget(&$widget, $form, $form_state, $field,
+function chado_linker__pub_widget(&$widget, $form, $form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
 
   $entity = $form['#entity'];
@@ -89,8 +89,8 @@ function tripal_chado_pub_widget(&$widget, $form, $form_state, $field,
 
   $widget['#table_name'] = $table_name;
   $widget['#fkey_field'] = $fkey;
-  $widget['#element_validate'] = array('tripal_chado_pub_widget_validate');
-  $widget['#theme'] = 'tripal_chado_pub_widget';
+  $widget['#element_validate'] = array('chado_linker__pub_widget_validate');
+  $widget['#theme'] = 'chado_linker__pub_widget';
   $widget['#prefix'] =  "<span id='$table_name-$delta'>";
   $widget['#suffix'] =  "</span>";
 
@@ -113,7 +113,7 @@ function tripal_chado_pub_widget(&$widget, $form, $form_state, $field,
     '#default_value' => $title,
     '#autocomplete_path' => 'admin/tripal/storage/chado/auto_name/pub',
     '#ajax' => array(
-      'callback' => "tripal_chado_pub_widget_form_ajax_callback",
+      'callback' => "chado_linker__pub_widget_form_ajax_callback",
       'wrapper' => "$table_name-$delta",
       'effect' => 'fade',
       'method' => 'replace'
@@ -124,7 +124,7 @@ function tripal_chado_pub_widget(&$widget, $form, $form_state, $field,
 /**
  * An Ajax callback for the pub widget.
  */
-function tripal_chado_pub_widget_form_ajax_callback($form, $form_state) {
+function chado_linker__pub_widget_form_ajax_callback($form, $form_state) {
 
   $field_name = $form_state['triggering_element']['#parents'][0];
   $delta = $form_state['triggering_element']['#parents'][2];
@@ -135,7 +135,7 @@ function tripal_chado_pub_widget_form_ajax_callback($form, $form_state) {
 /**
  * Callback function for validating the tripal_chado_organism_select_widget.
  */
-function tripal_chado_pub_widget_validate($element, &$form_state) {
+function chado_linker__pub_widget_validate($element, &$form_state) {
 
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
@@ -181,7 +181,7 @@ function tripal_chado_pub_widget_validate($element, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_chado_pub_widget($variables) {
+function theme_chado_linker__pub_widget($variables) {
   $element = $variables['element'];
 
   // These two fields were added to the widget to help identify the fields
@@ -213,7 +213,7 @@ function theme_tripal_chado_pub_widget($variables) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_pub_field_load($field, $entity, $base_table, $record) {
+function chado_linker__pub_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 8 - 8
tripal_chado/includes/fields/linker_synonym.inc → tripal_chado/includes/fields/chado_linker__synonym.inc

@@ -10,7 +10,7 @@
  * @param unknown $items
  * @param unknown $display
  */
-function tripal_chado_synonym_formatter(&$element, $entity_type, $entity, $field,
+function chado_linker__synonym_formatter(&$element, $entity_type, $entity, $field,
     $instance, $langcode, $items, $display) {
 
   $chado_table = $field['settings']['chado_table'];
@@ -41,7 +41,7 @@ function tripal_chado_synonym_formatter(&$element, $entity_type, $entity, $field
  * @param unknown $delta
  * @param unknown $element
  */
-function tripal_chado_synonym_widget(&$widget, $form, $form_state, $field,
+function chado_linker__synonym_widget(&$widget, $form, $form_state, $field,
     $instance, $langcode, $items, $delta, $element) {
 
   $entity = $form['#entity'];
@@ -100,8 +100,8 @@ function tripal_chado_synonym_widget(&$widget, $form, $form_state, $field,
 
   $widget['#table_name'] = $table_name;
   $widget['#fkey_field'] = $fkey;
-  $widget['#element_validate'] = array('tripal_chado_synonym_widget_validate');
-  $widget['#theme'] = 'tripal_chado_synonym_widget';
+  $widget['#element_validate'] = array('chado_linker__synonym_widget_validate');
+  $widget['#theme'] = 'chado_linker__synonym_widget';
   $widget['#prefix'] =  "<span id='$table_name-$delta'>";
   $widget['#suffix'] =  "</span>";
 
@@ -145,7 +145,7 @@ function tripal_chado_synonym_widget(&$widget, $form, $form_state, $field,
 /**
  * An Ajax callback for the synonym widget.
  */
-function tripal_chado_synonym_widget_form_ajax_callback($form, $form_state) {
+function chado_linker__synonym_widget_form_ajax_callback($form, $form_state) {
 
   $field_name = $form_state['triggering_element']['#parents'][0];
   $delta = $form_state['triggering_element']['#parents'][2];
@@ -156,7 +156,7 @@ function tripal_chado_synonym_widget_form_ajax_callback($form, $form_state) {
 /**
  * Callback function for validating the tripal_chado_organism_select_widget.
  */
-function tripal_chado_synonym_widget_validate($element, &$form_state) {
+function chado_linker__synonym_widget_validate($element, &$form_state) {
 
   $field_name = $element['#field_name'];
   $delta = $element['#delta'];
@@ -229,7 +229,7 @@ function tripal_chado_synonym_widget_validate($element, &$form_state) {
  *
  * @param $variables
  */
-function theme_tripal_chado_synonym_widget($variables) {
+function theme_chado_linker__synonym_widget($variables) {
   $element = $variables['element'];
 
   // These two fields were added to the widget to help identify the fields
@@ -270,7 +270,7 @@ function theme_tripal_chado_synonym_widget($variables) {
  * @param $base_table
  * @param $record
  */
-function tripal_chado_synonym_field_load($field, $entity, $base_table, $record) {
+function chado_linker__synonym_load($field, $entity, $base_table, $record) {
 
   $field_name = $field['field_name'];
   $field_type = $field['type'];

+ 2 - 2
tripal_chado/includes/tripal_chado.field_storage.inc

@@ -325,7 +325,7 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
         // 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';
+        $load_function = $field_type . '_load';
         module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
         if (function_exists($load_function)) {
           $load_function($field, $entity, $base_table, $record);
@@ -338,7 +338,7 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
       if ($field_table != $base_table) {
         // Set an empty value by default, and let the hook function update it.
         $entity->{$field_name}['und'][0]['value'] = '';
-        $load_function = $field_module . '_' . $field_type . '_field_load';
+        $load_function = $field_type . '_load';
         module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
         if (function_exists($load_function)) {
           $load_function($field, $entity, $base_table, $record);

+ 218 - 327
tripal_chado/includes/tripal_chado.fields.inc

@@ -11,8 +11,8 @@ function tripal_chado_field_info() {
     'chado_base__organism_id' => array(
       'label' => t('Organism'),
       'description' => t('A field for specifying an organism.'),
-      'default_widget' => 'tripal_chado_organism_select_widget',
-      'default_formatter' => 'tripal_chado_organism_formatter',
+      'default_widget' => 'chado_base__organism_id_widget',
+      'default_formatter' => 'chado_base__organism_id_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -20,26 +20,14 @@ function tripal_chado_field_info() {
         'active' => TRUE
       ),
     ),
+
     'chado_base__dbxref_id' => array(
       'label' => t('Cross reference'),
       'description' => t('This record can be cross referenced with a record in
           another online database. This field is intended for the most prominent
           reference.  At a minimum, the database and accession must be provided.'),
-      'default_widget' => 'tripal_chado_dbxref_id_widget',
-      'default_formatter' => 'tripal_chado_dbxref_id_formatter',
-      'settings' => array(),
-      'storage' => array(
-        'type' => 'field_chado_storage',
-        'module' => 'tripal_chado',
-        'active' => TRUE
-      ),
-    ),
-    'chado_base_pub_id' => array(
-      'label' => t('Publications'),
-      'description' => t('Associates a publication (e.g. journal article,
-          conference proceedings, book chapter, etc.) with this record.'),
-      'default_widget' => 'tripal_chado_pub_widget',
-      'default_formatter' => 'tripal_chado_pub_formatter',
+      'default_widget' => 'chado_base__dbxref_id_widget',
+      'default_formatter' => 'chado_base__dbxref_id_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -51,12 +39,12 @@ function tripal_chado_field_info() {
     /*
      * Fields that support linker tables.
      */
-    'chado_linker_cvterm' => array(
+    'chado_linker__cvterm' => array(
       'label' => t('Annotations'),
       'description' => t('This record can be annotated with terms
           from other vocabularies.'),
-      'default_widget' => 'tripal_chado_cvterm_widget',
-      'default_formatter' => 'tripal_chado_cvterm_formatter',
+      'default_widget' => 'chado_linker__cvterm_widget',
+      'default_formatter' => 'chado_linker__cvterm_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -64,11 +52,11 @@ function tripal_chado_field_info() {
         'active' => TRUE
       ),
     ),
-    'chado_linker_synonym' => array(
+    'chado_linker__synonym' => array(
       'label' => t('Synonyms'),
       'description' => t('Adds an alternative name (synonym or alias) to this record.'),
-      'default_widget' => 'tripal_chado_synonym_widget',
-      'default_formatter' => 'tripal_chado_synonym_formatter',
+      'default_widget' => 'chado_linker__synonym_widget',
+      'default_formatter' => 'chado_linker__synonym_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -76,11 +64,11 @@ function tripal_chado_field_info() {
         'active' => TRUE
       ),
     ),
-    'chado_linker_prop' => array(
+    'chado_linker__prop' => array(
       'label' => t('Add a Property'),
       'description' => t('Add details about this property.'),
-      'default_widget' => 'tripal_chado_kvproperty_widget',
-      'default_formatter' => 'tripal_chado_kvproperty_formatter',
+      'default_widget' => 'chado_linker__prop_widget',
+      'default_formatter' => 'chado_linker__prop_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -88,13 +76,26 @@ function tripal_chado_field_info() {
         'active' => TRUE
       ),
     ),
-    'chado_linker_dbxref' => array(
+    'chado_linker__dbxref' => array(
       'label' => t('Cross references'),
       'description' => t('This record can be cross referenced with a record in
         another online database. This field is intended for one or more
         references.  At a minimum, the database and accession must be provided.'),
-      'default_widget' => 'tripal_chado_dbxref_widget',
-      'default_formatter' => 'tripal_chado_dbxref_formatter',
+      'default_widget' => 'chado_linker__dbxref_widget',
+      'default_formatter' => 'chado_linker__dbxref_formatter',
+      'settings' => array(),
+      'storage' => array(
+        'type' => 'field_chado_storage',
+        'module' => 'tripal_chado',
+        'active' => TRUE
+      ),
+    ),
+    'chado_linker__pub' => array(
+      'label' => t('Publications'),
+      'description' => t('Associates a publication (e.g. journal article,
+          conference proceedings, book chapter, etc.) with this record.'),
+      'default_widget' => 'chado_linker__pub_widget',
+      'default_formatter' => 'chado_linker__pub_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -107,11 +108,11 @@ function tripal_chado_field_info() {
      * pages.  They are avaiable to site curators when adding/updating
      * a record and allow the user to add new linker table fields.
      */
-    'chado_linker_prop_adder' => array(
+    'chado_linker__prop_adder' => array(
       'label' => t('Add a Property Type'),
       'description' => t('This record may have any number of properties. Use
           this field to first add the type.'),
-      'default_widget' => 'tripal_chado_kvproperty_adder_widget',
+      'default_widget' => 'chado_linker__prop_adder_widget',
       'default_formatter' => 'hidden',
       'settings' => array(),
       'storage' => array(
@@ -124,11 +125,11 @@ function tripal_chado_field_info() {
     // The field provides a widget for adding new vocabularies for cvterm
     // linker tables. This will allow cvterms to be grouped by vocabulary
     // ('category').
-    'chado_linker_cvterm_adder' => array(
+    'chado_linker__cvterm_adder' => array(
       'label' => t('Add an Annotation Type'),
       'description' => t('This record may have any number of types of
           annotations. Use this field to first add the type.'),
-      'default_widget' => 'tripal_chado_cvterm_class_adder_widget',
+      'default_widget' => 'chado_linker__cvterm_adder_widget',
       'default_formatter' => 'hidden',
       'settings' => array(),
       'storage' => array(
@@ -143,8 +144,8 @@ function tripal_chado_field_info() {
     'chado_feature__residues' => array(
       'label' => t('Residues'),
       'description' => t('A field for managing nucleotide and protein residues.'),
-      'default_widget' => 'tripal_chado_residue_textarea_widget',
-      'default_formatter' => 'tripal_chado_residues_formatter',
+      'default_widget' => 'chado_feature__residues_widget',
+      'default_formatter' => 'chado_feature__residues_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -155,8 +156,8 @@ function tripal_chado_field_info() {
     'chado_feature__md5checksum' => array(
       'label' => t('MD5 checksum'),
       'description' => t('A field for generating MD5 checksum for a sequence.'),
-      'default_widget' => 'tripal_chado_md5checksum_checkbox_widget',
-      'default_formatter' => 'tripal_chado_md5checksum_formatter',
+      'default_widget' => 'chado_feature__md5checksum_widget',
+      'default_formatter' => 'chado_feature__md5checksum_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -167,8 +168,8 @@ function tripal_chado_field_info() {
     'chado_feature__seqlen' => array(
       'label' => t('Sequence length'),
       'description' => t('A field for calculating the length of a sequence.'),
-      'default_widget' => 'tripal_chado_seqlen_hidden_widget',
-      'default_formatter' => 'tripal_chado_seqlen_formatter',
+      'default_widget' => 'chado_feature__seqlen_widget',
+      'default_formatter' => 'chado_feature__seqlen_formatter',
       'settings' => array(),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -180,187 +181,6 @@ function tripal_chado_field_info() {
   );
   return $fields;
 }
-
-/**
- * Implements hook_field_formatter_settings_summary.
- */
-function tripal_chado_field_formatter_settings_summary($field, $instance, $view_mode) {
-
-  $summary = '';
-  switch ($field['type']) {
-    case 'organism_id':
-      $summary = 'Organisms can be displayed in vaious ways.';
-      break;
-    default:
-      $summary = '';
-  }
-
-  return $summary;
-}
-
-/**
- * Implements hook_field_formatter_settings_form.
- */
-function tripal_chado_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
-  $element = array();
-  switch ($field['type']) {
-    case 'chado_base__organism_id':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/organism_id');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/organism_id');
-      $element = tripal_chado_organism_select_formatter_form($field, $instance, $view_mode, $form, $form_state);
-      break;
-  }
-
-  return $element;
-}
-
-/**
- * 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 'chado_base__organism_id_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 'chado_base__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 'chado_base__pub_id_formatter':
-      module_load_include('inc', 'tripal_chado', 'includes/fields/pub');
-      tripal_chado_pub_formatter($element, $entity_type, $entity, $field,
-          $instance, $langcode, $items, $display);
-      break;
-    case 'chado_linker_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 'chado_linker_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 'chado_linker_prop_formatter':
-      module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty');
-      tripal_chado_kvproperty_formatter($element, $entity_type, $entity, $field,
-          $instance, $langcode, $items, $display);
-      break;
-    case 'chado_linker_synonym_formatter':
-      module_load_include('inc', 'tripal_chado', 'includes/fields/synonym');
-      tripal_chado_synonym_formatter($element, $entity_type, $entity, $field,
-          $instance, $langcode, $items, $display);
-      break;
-    case 'chado_linker_prop_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 'chado_linker_cvterm_adder_formatter':
-      module_load_include('inc', 'tripal_chado', 'includes/fields/cvterm_class_adder');
-      tripal_chado_cvterm_class_adder_formatter($element, $entity_type, $entity, $field,
-          $instance, $langcode, $items, $display);
-      break;
-    case 'chado_feature__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 'chado_feature__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 'chado_feature__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;
-
-
-  }
-  return $element;
-}
-
-/**
- * Implements hook_field_widget_form().
- */
-function tripal_chado_field_widget_form(&$form, &$form_state, $field,
-    $instance, $langcode, $items, $delta, $element) {
-
-  $widget = $element;
-  switch ($instance['widget']['type']) {
-    case 'chado_organism_select_widget':
-      // Make sure the include files get parsed now and for the form submits.
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/organism_id');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/organism_id');
-      // Update the widget with the new field.
-      tripal_chado_organism_select_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_dbxref_id_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/dbxref_id');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref_id');
-      tripal_chado_dbxref_id_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_dbxref_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/dbxref');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/dbxref');
-      tripal_chado_dbxref_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_cvterm_class_adder_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/cvterm_class_adder');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/cvterm_class_adder');
-      tripal_chado_cvterm_class_adder_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_cvterm_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/cvterm');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/cvterm');
-      tripal_chado_cvterm_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_md5checksum_checkbox_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/md5checksum');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/md5checksum');
-      tripal_chado_md5checksum_checkbox_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_residues_textarea_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/residues');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/residues');
-      tripal_chado_residues_textarea_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_seqlen_hidden_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/seqlen');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/seqlen');
-      tripal_chado_seqlen_hidden_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_kvproperty_adder_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/kvproperty_adder');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty_adder');
-      tripal_chado_kvproperty_adder_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_kvproperty_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/kvproperty');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/kvproperty');
-      tripal_chado_kvproperty_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_synonym_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/synonym');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/synonym');
-      tripal_chado_synonym_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-    case 'chado_pub_widget':
-      form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/pub');
-      module_load_include('inc', 'tripal_chado', 'includes/fields/pub');
-      tripal_chado_pub_widget($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
-      break;
-  }
-  return $widget;
-}
 /**
  * Implements hook_field_widget_info().
  */
@@ -368,79 +188,209 @@ function tripal_chado_field_widget_info() {
   return array(
     /*
      * Generic fields that support multiple base tables.
-     */
+  */
     'chado_base__organism_id_widget' => array(
       'label' => t('Organism Select'),
-      'field types' => array('organism_id')
+      'field types' => array('chado_base__organism_id')
     ),
     'chado_base__dbxref_id_widget' => array(
       'label' => t('Cross reference'),
-      'field types' => array('dbxref_id'),
+      'field types' => array('chado_base__dbxref_id'),
       'description' => t('This record can be cross referenced with a record in
         another online database. This field is intended for the most
         prominent reference.  At a minimum, the database and accession
         must be provided.'),
     ),
-    'chado_base__pub_id_widget' => array(
-      'label' => t('Publications'),
-      'field types' => array('pub'),
-    ),
+
     /*
      * Fields that support linker tables.
      */
-    'chado_linker_dbxref_widget' => array(
+    'chado_linker__pub_widget' => array(
+      'label' => t('Publications'),
+      'field types' => array('chado_linker__pub'),
+    ),
+    'chado_linker__dbxref_widget' => array(
       'label' => t('Cross references'),
-      'field types' => array('dbxref'),
+      'field types' => array('chado_linker__dbxref'),
       'description' => t('This record can be cross referenced with a record
         in another online database. This field is intended for the most
         prominent reference.  At a minimum, the database and accession
         must be provided.'),
     ),
 
-    'chado_linker_cvterm_widget' => array(
+    'chado_linker__cvterm_widget' => array(
       'label' => t('Annotations'),
-      'field types' => array('cvterm'),
+      'field types' => array('chado_linker__cvterm'),
       'description' => t('This record can be annotated with terms
           from other vocabularies.'),
     ),
-    'chado_linker_prop_widget' => array(
+    'chado_linker__prop_widget' => array(
       'label' => t('Property'),
-      'field types' => array('kvproperty'),
+      'field types' => array('chado_linker__prop'),
     ),
-    'chado_linker_synonym_widget' => array(
+    'chado_linker__synonym_widget' => array(
       'label' => t('Synonyms'),
-      'field types' => array('synonym'),
+      'field types' => array('chado_linker__synonym'),
     ),
     /*
      * Fields that add new fields. These fields are not shown on
      * pages.  They are avaiable to site curators when adding/updating
      * a record and allow the user to add new linker table fields.
      */
-    'chado_linker_prop_adder_widget' => array(
+    'chado_linker__prop_adder_widget' => array(
       'label' => t('Add a Property'),
-      'field types' => array('kvproperty_adder'),
+      'field types' => array('chado_linker__prop_adder'),
     ),
-    'chado_linker_cvterm_adder_widget' => array(
+    'chado_linker__cvterm_adder_widget' => array(
       'label' => t('Add an Annotation'),
-      'field types' => array('cvterm_class_adder'),
+      'field types' => array('chado_linker__cvterm_adder'),
     ),
     /*
      * Field specific to the feature table of Chado.
      */
     'chado_feature__md5checksum_widget' => array(
       'label' => t('MD5 Checksum Checkbox'),
-      'field types' => array('md5checksum'),
+      'field types' => array('chado_feature__md5checksum'),
     ),
     'chado_feature__residues_widget' => array(
       'label' => t('Residues'),
-      'field types' => array('residues'),
+      'field types' => array('chado_feature__residues'),
     ),
     'chado_feature__seqlen_widget' => array(
       'label' => t('Sequence Length'),
-      'field types' => array('seqlen'),
+      'field types' => array('chado_feature__seqlen'),
     ),
   );
 }
+/**
+ * Implements hook_field_formatter_info().
+ */
+function tripal_chado_field_formatter_info() {
+  return array(
+    'chado_base__organism_id_formatter' => array(
+      'label' => t('Organism'),
+      'field types' => array('chado_base__organism_id')
+    ),
+    'chado_base__dbxref_id_formatter' => array(
+      'label' => t('Cross reference'),
+      'field types' => array('chado_base__dbxref_id')
+    ),
+    'chado_linker__pub_formatter' => array(
+      'label' => t('Publications'),
+      'field types' => array('chado_linker__pub')
+    ),
+    'chado_linker__dbxref_formatter' => array(
+      'label' => t('Cross references'),
+      'field types' => array('chado_linker__dbxref')
+    ),
+    'chado_linker__cvterm_formatter' => array(
+      'label' => t('Annotations'),
+      'field types' => array('chado_linker__cvterm')
+    ),
+    'chado_linker__prop_formatter' => array(
+      'label' => t('Property'),
+      'field types' => array('chado_linker__prop')
+    ),
+    'chado_linker__synonym_formatter' => array(
+      'label' => t('Synonyms'),
+      'field types' => array('chado_linker__synonym')
+    ),
+
+    'chado_linker__cvterm_adder_formatter' => array(
+      'label' => t('Add an Annotation'),
+      'field types' => array('chado_linker__cvterm_adder')
+    ),
+
+    'chado_linker__prop_adder_formatter' => array(
+      'label' => t('Add a Property'),
+      'field types' => array('chado_linker__prop_adder')
+    ),
+
+    'chado_feature__md5checksum_formatter' => array(
+      'label' => t('MD5 checksum'),
+      'field types' => array('chado_feature__md5checksum')
+    ),
+    'chado_feature__residues_formatter' => array(
+      'label' => t('Residues'),
+      'field types' => array('chado_feature__residues')
+    ),
+    'chado_feature__seqlen_formatter' => array(
+      'label' => t('Sequence length'),
+      'field types' => array('chado_feature__seqlen')
+    ),
+  );
+}
+/**
+ * Implements hook_field_formatter_settings_summary.
+ */
+function tripal_chado_field_formatter_settings_summary($field, $instance, $view_mode) {
+
+  $summary = '';
+  switch ($field['type']) {
+    case 'organism_id':
+      $summary = 'Organisms can be displayed in vaious ways.';
+      break;
+    default:
+      $summary = '';
+  }
+
+  return $summary;
+}
+
+/**
+ * Implements hook_field_formatter_settings_form.
+ */
+function tripal_chado_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+  $element = array();
+
+  $field_type = $field['type'];
+  form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  $function = $field_type . '_formatter_form';
+  if (function_exists($function)) {
+    $element = $function($field, $instance, $view_mode, $form, $form_state);
+  }
+
+  return $element;
+}
+
+/**
+ * Implements hook_field_formatter_view().
+ */
+function tripal_chado_field_formatter_view($entity_type, $entity, $field,
+    $instance, $langcode, $items, $display) {
+
+  $element = array();
+
+  $field_type = $display['type'];
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  $function = $field_type;
+  if (function_exists($function)) {
+    $function($element, $entity_type, $entity, $field, $instance, $langcode, $items, $display);
+  }
+
+  return $element;
+}
+
+/**
+ * Implements hook_field_widget_form().
+ */
+function tripal_chado_field_widget_form(&$form, &$form_state, $field,
+    $instance, $langcode, $items, $delta, $element) {
+
+  $widget = $element;
+
+  $field_type = $instance['widget']['type'];
+  form_load_include($form_state, 'inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  $function = $field_type;
+  if (function_exists($function)) {
+    $function($widget, $form, $form_state, $field, $instance, $langcode, $items, $delta, $element);
+  }
+
+  return $widget;
+}
+
 /**
  * Returns the values of the field from the $form_state.
  */
@@ -531,72 +481,13 @@ function tripal_chado_field_widget_form_alter(&$element, &$form_state, $context)
   }
 }
 
-/**
- * Implements hook_field_formatter_info().
- */
-function tripal_chado_field_formatter_info() {
-  return array(
-    'chado_base__organism_id_formatter' => array(
-      'label' => t('Organism'),
-      'field types' => array('organism_id')
-    ),
-    'chado_base__dbxref_id_formatter' => array(
-      'label' => t('Cross reference'),
-      'field types' => array('dbxref_id')
-    ),
-    'chado_base__pub_id_formatter' => array(
-      'label' => t('Publications'),
-      'field types' => array('pub')
-    ),
-
-
-    'chado_linker_dbxref_formatter' => array(
-      'label' => t('Cross references'),
-      'field types' => array('dbxref')
-    ),
-    'chado_linker_cvterm_formatter' => array(
-      'label' => t('Annotations'),
-      'field types' => array('cvterm')
-    ),
-    'chado_linker_prop_formatter' => array(
-      'label' => t('Property'),
-      'field types' => array('kvproperty')
-    ),
-    'chado_linker_synonym_formatter' => array(
-      'label' => t('Synonyms'),
-      'field types' => array('synonym')
-    ),
-
-    'chado_linker_cvterm_adder_formatter' => array(
-      'label' => t('Add an Annotation'),
-      'field types' => array('cvterm_class_adder')
-    ),
 
-    'chado_linker_prop_adder_formatter' => array(
-      'label' => t('Add a Property'),
-      'field types' => array('kvproperty_adder')
-    ),
-
-    'chado_feature__md5checksum_formatter' => array(
-      'label' => t('MD5 checksum'),
-      'field types' => array('md5checksum')
-    ),
-    'chado_feature__residues_formatter' => array(
-      'label' => t('Residues'),
-      'field types' => array('residues')
-    ),
-    'chado_feature__seqlen_formatter' => array(
-      'label' => t('Sequence length'),
-      'field types' => array('seqlen')
-    ),
-  );
-}
 
 /**
  * Returns a $field_info array for a field based on a database column.
  *
  */
-function tripal_chado_add_bundle_fields_base_fields_defaults($table_name, $schema, $column_name) {
+function tripal_chado_add_bundle_fields_base__fields_defaults($table_name, $schema, $column_name) {
   $details = $schema['fields'][$column_name];
 
   // Create an array with information about this field.
@@ -704,7 +595,7 @@ function tripal_chado_add_bundle_fields_base_fields_defaults($table_name, $schem
   //
   if ($field['field_settings']['chado_column'] == 'organism_id') {
     $field['field_type'] = 'chado_base__organism_id';
-    $field['widget_type'] = 'tripal_chado_organism_select_widget';
+    $field['widget_type'] = 'chado_base__organism_id_widget';
     $field['label'] = 'Organism';
     $field['description'] = 'Select an organism.';
     $field['field_settings']['semantic_web']['type'] = 'organism';
@@ -714,7 +605,7 @@ function tripal_chado_add_bundle_fields_base_fields_defaults($table_name, $schem
   }
   elseif ($field['field_settings']['chado_column'] =='dbxref_id') {
     $field['field_type'] = 'chado_base__dbxref_id';
-    $field['widget_type'] = 'tripal_chado_primary_dbxref_widget';
+    $field['widget_type'] = 'chado_base_dbxref_id_widget';
     $field['label'] = 'Cross Reference';
     $field['description'] = 'This record can be cross referenced with a ' .
         'record in another online database. The primary reference is for the ' .
@@ -969,7 +860,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // Adds the fields for the base table to the entity.  Adds fields
   // for all columns including FK fields.  Excludes primary key and the
   // type_id field (that's inherent in the bundle).
-  tripal_chado_add_bundle_fields_base_fields($entity_type, $bundle_name, $bundle_data);
+  tripal_chado_add_bundle_fields_base__fields($entity_type, $bundle_name, $bundle_data);
 
   ////
   //
@@ -979,7 +870,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // base table. If so, add the fields for that type of table.
   $prop_table = $bundle_data['data_table'] . 'prop';
   if (chado_table_exists($prop_table)) {
-    tripal_chado_add_bundle_fields_kvproperty_adder_field($entity_type, $bundle_name, $prop_table, $bundle_data['data_table']);
+    tripal_chado_add_bundle_fields_linker__prop_adder_field($entity_type, $bundle_name, $prop_table, $bundle_data['data_table']);
   }
 
   ////
@@ -990,7 +881,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // base table. If so, add the fields for that type of table.
   $dbxref_table = $bundle_data['data_table'] . '_dbxref';
   if (chado_table_exists($dbxref_table)) {
-    tripal_chado_add_bundle_fields_dbxref_field($entity_type, $bundle_name, $dbxref_table, $bundle_data['data_table']);
+    tripal_chado_add_bundle_fields_linker__dbxref_field($entity_type, $bundle_name, $dbxref_table, $bundle_data['data_table']);
   }
 
   ////
@@ -1001,7 +892,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // base table. If so, add the fields for that type of table.
   $cvterm_table = $bundle_data['data_table'] . '_cvterm';
   if (chado_table_exists($cvterm_table)) {
-    tripal_chado_add_bundle_fields_cvterm_class_adder_field($entity_type, $bundle_name, $cvterm_table, $bundle_data['data_table']);
+    tripal_chado_add_bundle_fields_linker__cvterm_adder_field($entity_type, $bundle_name, $cvterm_table, $bundle_data['data_table']);
   }
 
 
@@ -1013,7 +904,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // base table. If so, add the fields for that type of table.
   $syn_table = $bundle_data['data_table'] . '_synonym';
   if (chado_table_exists($syn_table)) {
-    tripal_chado_add_bundle_fields_synonym_field($entity_type, $bundle_name, $syn_table, $bundle_data['data_table']);
+    tripal_chado_add_bundle_fields_linker__synonym_field($entity_type, $bundle_name, $syn_table, $bundle_data['data_table']);
   }
 
   ////
@@ -1024,7 +915,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
   // base table. If so, add the fields for that type of table.
   $pub_table = $bundle_data['data_table'] . '_pub';
   if (chado_table_exists($pub_table)) {
-    tripal_chado_add_bundle_fields_pub_field($entity_type, $bundle_name, $pub_table, $bundle_data['data_table']);
+    tripal_chado_add_bundle_fields_linker__pub_field($entity_type, $bundle_name, $pub_table, $bundle_data['data_table']);
   }
 }
 
@@ -1036,7 +927,7 @@ function tripal_chado_add_bundle_fields($entity_type, $bundle, $term) {
  * @param $base_table
  * @param $dbxref_table
  */
-function tripal_chado_add_bundle_fields_dbxref_field($entity_type_name, $bundle_name, $dbxref_table, $base_table) {
+function tripal_chado_add_bundle_fields_linker__dbxref_field($entity_type_name, $bundle_name, $dbxref_table, $base_table) {
   // We already have a dbxref_id field.
   $field_name = $dbxref_table;
   $schema = chado_get_schema($dbxref_table);
@@ -1044,8 +935,8 @@ function tripal_chado_add_bundle_fields_dbxref_field($entity_type_name, $bundle_
 
   // Initialize the field array.
   $field_info = array(
-    'field_type' => 'chado_linker_dbxref_adder',
-    'widget_type' => 'chado_linker_dbxref_adder_widget',
+    'field_type' => 'chado_base__dbxref_id',
+    'widget_type' => 'chado_base__dbxref_id_widget',
     'widget_settings' => array('display_label' => 1),
     'description' => '',
     'label' => 'Cross References',
@@ -1087,7 +978,7 @@ function tripal_chado_add_bundle_fields_dbxref_field($entity_type_name, $bundle_
  * @param $base_table
  * @param $dbxref_table
  */
-function tripal_chado_add_bundle_fields_synonym_field($entity_type_name, $bundle_name, $syn_table, $base_table) {
+function tripal_chado_add_bundle_fields_linker__synonym_field($entity_type_name, $bundle_name, $syn_table, $base_table) {
   // We already have a dbxref_id field.
   $field_name = $syn_table;
   $schema = chado_get_schema($syn_table);
@@ -1095,8 +986,8 @@ function tripal_chado_add_bundle_fields_synonym_field($entity_type_name, $bundle
 
   // Initialize the field array.
   $field_info = array(
-    'field_type' => 'chado_linker_synonym',
-    'widget_type' => 'chado_linker_synonym_widget',
+    'field_type' => 'chado_linker__synonym',
+    'widget_type' => 'chado_linker__synonym_widget',
     'widget_settings' => array('display_label' => 1),
     'description' => '',
     'label' => 'Synonyms',
@@ -1132,7 +1023,7 @@ function tripal_chado_add_bundle_fields_synonym_field($entity_type_name, $bundle
  * @param $base_table
  * @param $dbxref_table
  */
-function tripal_chado_add_bundle_fields_pub_field($entity_type_name, $bundle_name, $pub_table, $base_table) {
+function tripal_chado_add_bundle_fields_linker__pub_field($entity_type_name, $bundle_name, $pub_table, $base_table) {
   // We already have a dbxref_id field.
   $field_name = $pub_table;
   $schema = chado_get_schema($pub_table);
@@ -1140,8 +1031,8 @@ function tripal_chado_add_bundle_fields_pub_field($entity_type_name, $bundle_nam
 
   // Initialize the field array.
   $field_info = array(
-    'field_type' => 'chado_base__pub_id',
-    'widget_type' => 'chado_base__pub_id_widget',
+    'field_type' => 'chado_linker__pub',
+    'widget_type' => 'chado_linker__pub_widget',
     'widget_settings' => array('display_label' => 1),
     'description' => '',
     'label' => 'Publications',
@@ -1176,13 +1067,13 @@ function tripal_chado_add_bundle_fields_pub_field($entity_type_name, $bundle_nam
  * @param $bundle_name
  * @param $kv_table
  */
-function tripal_chado_add_bundle_fields_kvproperty_adder_field($entity_type_name, $bundle_name, $kv_table, $base_table) {
+function tripal_chado_add_bundle_fields_linker__prop_adder_field($entity_type_name, $bundle_name, $kv_table, $base_table) {
   $field_name = $kv_table;
 
   // Initialize the field array.
   $field_info = array(
-    'field_type' => 'chado_linker_prop_adder',
-    'widget_type' => 'chado_linker_prop_adder_widget',
+    'field_type' => 'chado_linker__prop_adder',
+    'widget_type' => 'chado_linker__prop_adder_widget',
     'field_settings' => array(
       'base_table' => $base_table,
     ),
@@ -1201,14 +1092,14 @@ function tripal_chado_add_bundle_fields_kvproperty_adder_field($entity_type_name
  * @param $bundle_name
  * @param $kv_table
  */
-function tripal_chado_add_bundle_fields_cvterm_class_adder_field($entity_type_name, $bundle_name, $cvterm_table, $base_table) {
+function tripal_chado_add_bundle_fields_linker__cvterm_adder_field($entity_type_name, $bundle_name, $cvterm_table, $base_table) {
   // First add a generic property field so that users can add new property types.
   $field_name = $cvterm_table;
 
   // Initialize the field array.
   $field_info = array(
-    'field_type' => 'chado_linker_cvterm_adder',
-    'widget_type' => 'chado_linker_cvterm_adder_widget',
+    'field_type' => 'chado_linker__cvterm_adder',
+    'widget_type' => 'chado_linker__cvterm_adder_widget',
     'field_settings' => array(
       'base_table' => $base_table,
     ),
@@ -1223,7 +1114,7 @@ function tripal_chado_add_bundle_fields_cvterm_class_adder_field($entity_type_na
 /**
  * Adds the fields for the base table to the entity.
  */
-function tripal_chado_add_bundle_fields_base_fields($entity_type_name, $bundle_name, $bundle_data) {
+function tripal_chado_add_bundle_fields_base__fields($entity_type_name, $bundle_name, $bundle_data) {
 
   $table_name = $bundle_data['data_table'];
   $type_table = $bundle_data['type_table'];
@@ -1247,7 +1138,7 @@ function tripal_chado_add_bundle_fields_base_fields($entity_type_name, $bundle_n
     }
 
     // Get the field defaults for this column.
-    $field_info = tripal_chado_add_bundle_fields_base_fields_defaults($table_name, $schema, $column_name);
+    $field_info = tripal_chado_add_bundle_fields_base__fields_defaults($table_name, $schema, $column_name);
 
 
     // TODO: add in a call to drupal_alter to allow other modules to change

+ 83 - 86
tripal_chado/includes/tripal_chado.term_storage.inc

@@ -93,60 +93,72 @@ function tripal_chado_vocab_import_form_submit($form, &$form_state) {
  * Implements hook_vocab_select_term_form().
  */
 function tripal_chado_vocab_select_term_form($form, &$form_state) {
-  $term_name = '';
-  $num_terms = 0;
-  $cv_id = '';
-  $terms = array();
-
-  // Set defaults using the form state.
-  if (array_key_exists('storage', $form_state)) {
-    if (array_key_exists('terms', $form_state['storage'])) {
-      $terms = $form_state['storage']['terms'];
-    }
-  }
-  $num_terms = count($terms);
+  $term_name = array_key_exists('values', $form_state) ? $form_state['values']['term_name'] : '';
 
   // If no term has been selected yet then provide the auto complete field.
-  if ($num_terms == 0) {
-    $form['term_name'] = array(
-      '#title'       => t('Content Type'),
-      '#type'        => 'textfield',
-      '#description' => t("The content type must be the name of a term in
-          a controlled vocabulary and the controlled vocabulary should
-          already be loaded into Tripal.  For example, to create a content
-          type for storing 'genes', use the 'gene' term from the
-          Sequence Ontology (SO)."),
-      '#required'    => TRUE,
-      '#default_value' => $term_name,
-      '#autocomplete_path' => "admin/tripal/storage/term/$cv_id",
-    );
-  }
+  $form['term_name'] = array(
+    '#title'       => t('Content Type'),
+    '#type'        => 'textfield',
+    '#description' => t("The content type must be the name of a term in
+        a controlled vocabulary and the controlled vocabulary should
+        already be loaded into Tripal.  For example, to create a content
+        type for storing 'genes', use the 'gene' term from the
+        Sequence Ontology (SO)."),
+    '#required'    => TRUE,
+    '#default_value' => $term_name,
+    '#autocomplete_path' => "admin/tripal/storage/term/",
+  );
+  $form['select_button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Lookup Term'),
+    '#name' => 'select_cvterm',
+    '#ajax' => array(
+      'callback' => "tripal_chado_vocab_select_term_form_ajax_callback",
+      'wrapper' => "tripal-chado-vocab-select-form",
+      'effect' => 'fade',
+      'method' => 'replace'
+    ),
+  );
 
-  // If the term belongs to more than one vocabulary then add additional fields
-  // to let the user select the vocabulary.
-  if ($num_terms > 1) {
-    $form['term_name'] = array(
-      '#type' => 'hidden',
-      '#value' => $term_name,
+  if ($term_name) {
+    $form['terms_list'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Matching Terms'),
+      '#description' => t('Please select the term the best matches the
+          content type you want to create. If the same term exists in
+          multiple vocabularies you will see more than one option below.')
     );
-
-    $cvs = array();
+    $match = array(
+      'name' => $term_name,
+    );
+    $terms = chado_generate_var('cvterm', $match, array('return_array' => TRUE));
+    $terms = chado_expand_var($terms, 'field', 'cvterm.definition');
     foreach ($terms as $term) {
-      $cvs[$term->cv_id->cv_id] = 'Vocabulary: <b>' . $term->cv_id->name . '</b> (' . $term->cv_id->definition . ')<br>' . $term->name . ': ' . $term->definition;
+       $form['terms_list']['term-' . $term->cvterm_id] = array(
+         '#type' => 'checkbox',
+         '#title' =>  $term->name,
+         '#description' => '<b>Term: </b> ' . $term->dbxref_id->db_id->name . ':' . $term->dbxref_id->accession . '.  ' .
+             '<br><b>Definition:</b>  ' . $term->definition,
+       );
     }
-    $form['cv_id'] = array(
-      '#type' => 'radios',
-      '#title' => t('Select the appropriate vocabulary'),
-      '#options' => $cvs,
+    // Add in the button for the cases of no terms or too many.
+    $form['submit_button'] = array(
+      '#type' => 'submit',
+      '#value' => t('Use this term'),
+      '#name' => 'use_cvterm'
     );
   }
 
-  // Add in the button for the cases of no terms or too many.
-  $form['select_button'] = array(
-    '#type' => 'submit',
-    '#value' => t('Use this term'),
-    '#name' => 'select_cvterm'
-  );
+  $form['#prefix'] = '<div id = "tripal-chado-vocab-select-form">';
+  $form['#suffix'] = '</div>';
+
+  return $form;
+}
+
+/**
+ * Implements an AJAX callback for the tripal_chado_vocab_select_term_form.
+ */
+function tripal_chado_vocab_select_term_form_ajax_callback($form, $form_state) {
   return $form;
 }
 
@@ -154,53 +166,38 @@ function tripal_chado_vocab_select_term_form($form, &$form_state) {
  * Implements hook_vocab_select_term_form_validate().
  */
 function tripal_chado_vocab_select_term_form_validate($form, &$form_state) {
+
   if (array_key_exists('clicked_button', $form_state) and
-      $form_state['clicked_button']['#name'] =='select_cvterm') {
+      $form_state['clicked_button']['#name'] =='use_cvterm') {
 
-    // First, make sure the term is unique. If not then we can't check it.
-    $term_name = NULL;
-    $cv_id = NULL;
-    $cvterm = NULL;
-    if (array_key_exists('term_name', $form_state['values'])) {
-      $term_name = $form_state['input']['term_name'];
-    }
-    if (array_key_exists('cv_id', $form_state['input'])) {
-      $cv_id = $form_state['input']['cv_id'];
-    }
+    $cvterm_id = NULL;
 
-    // If a term and $cv_id are provided then we can look for the term using
-    // both and we should find a unique term. If only ther term is provided
-    // we can still look for a unique term but there must only be one.
-    if ($term_name and !$cv_id) {
-      $match = array(
-        'name' => $term_name,
-      );
+    // Make sure we have a cvterm selected
+    $num_selected = 0;
+    foreach ($form_state['values'] as $key => $value) {
+      $matches = array();
+      if (preg_match("/^term-(\d+)$/", $key, $matches) and
+          $form_state['values']['term-' . $matches[1]]) {
+        $cvterm_id = $matches[1];
+        $term = chado_generate_var('cvterm', array('cvterm_id' => $cvterm_id));
+        $num_selected++;
+      }
     }
-    else {
-      $match = array(
-        'name' => $term_name,
-        'cv_id' => $cv_id,
-      );
+    if ($num_selected == 0) {
+      form_set_error('', 'Please select at least one term.');
     }
-    $terms = chado_generate_var('cvterm', $match, array('return_array' => TRUE));
-    $form_state['storage']['terms'] = $terms;
-
-    // If we do not have any terms then the term provided by the user does not
-    // exists and we need to provide an error message.
-    if (count($terms) == 0) {
-      form_set_error('term_name', t('The term does not exist in this database.'));
+    else if ($num_selected > 1) {
+      form_set_error('term-' . $cvterm_id, 'Please select only one term from the list below.');
     }
-    // If we have more than one term then we need to set an error so that the
-    // form can provide a list of vocabularies to select from.
-    if (count($terms) > 1) {
-      form_set_error('term_name', t('The term is not unique. A list of vocabularies
-        that contain this term. Please select the most appropriate vocabulary.'));
-    }
-    // If we have a unique term then set the namespace, accession and name.
-    if (count($terms) == 1) {
-      $form_state['storage']['namespace'] = $terms[0]->dbxref_id->db_id->name;
-      $form_state['storage']['accession'] = $terms[0]->dbxref_id->accession;
-      $form_state['storage']['term_name'] = $terms[0]->name;
+    else {
+      $form_state['storage']['namespace'] = $term->dbxref_id->db_id->name;
+      $form_state['storage']['accession'] = $term->dbxref_id->accession;
+      $form_state['storage']['term_name'] = $term->name;
     }
   }
+  // For any other button click it's an AJAX call and we just want to reubild
+  // the form.
+  else {
+    $form_state['rebuild'] = TRUE;
+  }
 }

+ 11 - 11
tripal_chado/tripal_chado.module

@@ -506,27 +506,27 @@ function tripal_chado_theme($existing, $type, $theme, $path) {
     // Theme fields.
     'chado_base__dbxref_id_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/base__dbxref_id.inc',
+      'file' => 'includes/fields/chado_base__dbxref_id.inc',
     ),
-    'chado_linker_dbxref_widget' => array(
+    'chado_linker__dbxref_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/linker_dbxref.inc',
+      'file' => 'includes/fields/chado_linker__dbxref.inc',
     ),
-    'chado_linker_cvterm_widget' => array(
+    'chado_linker__cvterm_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/cvterm.inc',
+      'file' => 'includes/fields/chado_linker__cvterm.inc',
     ),
-    'chado_linker_synonym_widget' => array(
+    'chado_linker__synonym_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/synonym.inc',
+      'file' => 'includes/fields/chado_linker__synonym.inc',
     ),
-    'chado_base__pub_id_widget' => array(
+    'chado_linker__pub_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/pub.inc',
+      'file' => 'includes/fields/chado_linker__pub.inc',
     ),
-    'chado_linker_prop_adder_widget' => array(
+    'chado_linker__prop_adder_widget' => array(
       'render element' => 'element',
-      'file' => 'includes/fields/dbxref_id.inc',
+      'file' => 'includes/fields/chado_linker__prop_adder.inc',
     ),
     'tripal_chado_date_combo' => array(
       'render element' => 'element',