Browse Source

Merge pull request #764 from tripal/717_attach_linker_contact

resolve content creation bug w/ contact field: attach linker contact field instead of base field
Lacey-Anne Sanderson 6 years ago
parent
commit
c3b0ea1914
2 changed files with 31 additions and 2 deletions
  1. 2 2
      tripal_chado/includes/tripal_chado.fields.inc
  2. 29 0
      tripal_chado/tripal_chado.install

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

@@ -2241,7 +2241,7 @@ function tripal_chado_bundle_instances_info_linker(&$info, $entity_type, $bundle
         'term_name' => 'contact',
       ),
       'widget' => array(
-        'type' => 'local__contact_widget',
+        'type' => 'chado_linker__contact_widget',
         'settings' => array(
           'display_label' => 1,
         ),
@@ -2249,7 +2249,7 @@ function tripal_chado_bundle_instances_info_linker(&$info, $entity_type, $bundle
       'display' => array(
         'default' => array(
           'label' => 'hidden',
-          'type' => 'local__contact_formatter',
+          'type' => 'chado_linker__contact_formatter',
           'settings' => array(),
         ),
       ),

+ 29 - 0
tripal_chado/tripal_chado.install

@@ -1825,3 +1825,32 @@ function tripal_chado_update_7335() {
     throw new DrupalUpdateException('Could not perform update: '. $error);
   }
 }
+
+
+
+/**
+ * Use correct contact field when linked via linker table.
+ */
+function tripal_chado_update_7336() {
+
+  $bundles = field_info_instances('TripalEntity');
+
+  foreach ($bundles as $bundle_name => $fields) {
+
+    $bundle = tripal_load_bundle_entity(['name' => $bundle_name]);
+    $base = $bundle->data_table;
+
+    $contact_table = $base . '_contact';
+    if (chado_table_exists($contact_table)) {
+
+      $field_name = $base . '_contact';
+      $instance_info = field_info_instance('TripalEntity', $field_name, $bundle_name);
+
+      $instance_info['type'] = 'chado_linker__contact';
+      $instance_info['widget']['type'] = 'chado_linker__contact_widget';
+      $instance_info['formatter']['type'] = 'chado_linker__contact_widget';
+      field_update_instance($instance_info);
+      
+    }
+  }
+}