Browse Source

Fixed a undefined index warning on the schema__additional_type field and fixed a bug where a field for the organism type was being added twice

Stephen Ficklin 6 years ago
parent
commit
d4ee36803e

+ 2 - 0
tripal_chado/includes/TripalFields/schema__additional_type/schema__additional_type_widget.inc

@@ -44,6 +44,7 @@ class schema__additional_type_widget extends ChadoFieldWidget {
     // If a parent_term is provided then use that to get the options
     $options = array();
     $options[] = 'Select a type';
+    $vocabulary = '';
     if ($enforce_parent_term) {
       list ($vocabulary, $accession) = explode(':', $enforce_parent_term);
       if ($vocabulary and $accession) {
@@ -70,6 +71,7 @@ class schema__additional_type_widget extends ChadoFieldWidget {
       }
     }
     elseif ($enforce_vocabulary) {
+      $vocabulary = $enforce_vocabulary;
       $cv = chado_get_cv(array('name' => $enforce_vocabulary));
       $options = chado_get_cvterm_select_options($cv->cv_id);
     }

+ 5 - 3
tripal_chado/includes/tripal_chado.fields.inc

@@ -223,8 +223,10 @@ function tripal_chado_bundle_fields_info_custom(&$info, $details, $entity_type,
 
   $schema = chado_get_schema($table_name);
 
-  // Handle type_id fields that are not the type_column.
-  if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column) {
+  // Handle type_id fields that are not the type_column, except for the
+  // organism type_id as that is handled by the taxrank__infraspecific_taxon
+  // field.
+  if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column and $table_name != 'organism') {
     $field_name = 'schema__additional_type';
     $field_type = 'schema__additional_type';
     $info[$field_name] = array(
@@ -1293,7 +1295,7 @@ function tripal_chado_bundle_instances_info_custom(&$info, $entity_type, $bundle
   $schema = chado_get_schema($table_name);
 
   // An additional type for publications
-  if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column) {
+  if (array_key_exists('type_id', $schema['fields']) and 'type_id' != $type_column and $table_name != 'organism') {
     $field_name = 'schema__additional_type';
     $is_required = FALSE;
     if (array_key_exists('not null', $schema['fields']['type_id']) and