ソースを参照

Fixed bugs introduced by adding field instanceSettingsForm

Chun-Huai Cheng 8 年 前
コミット
952b44bf59

+ 9 - 7
tripal_chado/includes/tripal_chado.entity.inc

@@ -212,9 +212,9 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
         // TODO: what to do if record is missing!
       }
       // Get some values needed for loading the values from Chado.
-      $base_table = $details->data_table;
-      $type_field = $details->field;
-      $record_id = $details->record_id;
+      $base_table = isset($details->data_table) ? $details->data_table : '';
+      $type_field = isset($details->field) ? $details->field : '';
+      $record_id = isset($details->record_id) ? $details->record_id : '';
     }
 
     // Get this table's schema.
@@ -230,9 +230,11 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
     // For now, expand all 'text' fields.
     // TODO: we want to be a bit smarter and allow the user to configure this
     // for now we'll expand.
-    foreach ($schema['fields'] as $field_name => $details) {
-      if ($schema['fields'][$field_name]['type'] == 'text') {
-        $record = chado_expand_var($record, 'field', $base_table . '.' . $field_name);
+    if (isset($schema['fields'])) {
+      foreach ($schema['fields'] as $field_name => $details) {
+        if ($schema['fields'][$field_name]['type'] == 'text') {
+          $record = chado_expand_var($record, 'field', $base_table . '.' . $field_name);
+        }
       }
     }
 
@@ -300,7 +302,7 @@ function tripal_chado_field_storage_load($entity_type, $entities, $age,
         $entity->{$field_name}['und'][0]['value'] = '';
         $load_function = $field_type . '_load';
         module_load_include('inc', $field_module, 'includes/fields/' . $field_type);
-        if (class_exists($field_type)) {
+        if (class_exists($field_type) && method_exists($field_type, 'load')) {
           $field_type::load($field, $entity, array('record' => $record));
         }
       }

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

@@ -556,7 +556,7 @@ function tripal_chado_field_settings_form_validate($form, &$form_state) {
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
   if (class_exists($field_type)) {
-    $form = $field_type::settingsFormValidate($field, $instance, $form, $form_state);
+    $form = $field_type::fieldSettingsFormValidate($field, $instance, $form, $form_state);
   }
 }
 /**
@@ -566,7 +566,7 @@ function tripal_chado_field_settings_form_validate($form, &$form_state) {
  * to alow the TripalField objects to have a instanceSettingsFormValidate()
  * member function.
  */
-function tripal_chado_field_settings_form_validate($form, &$form_state) {
+function tripal_chado_instance_settings_form_validate($form, &$form_state) {
   $field = $form['#field'];
   $instance = $form['#instance'];
   $field_type = $field['type'];