Răsfoiți Sursa

Fixed bug with ajax attaching of fields and with expanding base fields that are of type text

Stephen Ficklin 8 ani în urmă
părinte
comite
5e476d806e

+ 3 - 2
tripal/includes/tripal.entity.inc

@@ -339,12 +339,13 @@ function tripal_ajax_attach_field($id) {
   if (preg_match('/^tripal-entity-(\d+)--(.+)$/', $id, $matches)) {
     $entity_id = $matches[1];
     $field_name = $matches[2];
-    $field = field_info_fields($field_name);
+    $field = field_info_field($field_name);
     $result = tripal_load_entity('TripalEntity', array($entity_id), FALSE, array($field['id']));
     reset($result);
     $entity = $result[$entity_id];
 
-    $content = drupal_render(field_view_field('TripalEntity', $entity, $field_name));
+    $element = field_view_field('TripalEntity', $entity, $field_name);
+    $content = drupal_render($element);
     return drupal_json_output(array(
       'id' => $id,
       'content' => $content

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

@@ -279,6 +279,14 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
           $tfield = new $field_type($field, $instance);
           $tfield->load($entity, array('record' => $record));
         }
+        // For text fields that were not handled by a TripalField class we 
+        // want to automatically expand those fields. 
+        else {
+          if ($schema['fields'][$field_column]['type'] == 'text') {
+            $record = chado_expand_var($record, 'field', "$field_table.$field_column");
+            $entity->{$field_name}['und'][0]['value'] = $record->$field_column;
+          }
+        }
       }
 
       // Type 2: fields for linked records.  These fields will have any number
@@ -643,4 +651,4 @@ function tripal_chado_field_storage_query_build_sql(&$sql, $prev_table, $prev_co
       // unrecognized operation.
       break;
   }
-}
+}