Browse Source

Fixed bug in pager of relationship field. And bug in tripal_field_is_empty() function

Stephen Ficklin 7 years ago
parent
commit
4ac4c84cd7

+ 6 - 8
tripal/includes/tripal.fields.inc

@@ -853,16 +853,14 @@ function tripal_field_is_empty($item, $field) {
     return TRUE;
   }
 
-  // Iterate through all of the fields and if at least one has a value
-  // the field is not empty.
-  foreach ($item as $form_field_name => $value) {
-    if (isset($value) and $value != NULL and $value != '') {
-      return FALSE;
-    }
+  // If there is a value field but there's nothing in it, the the field is
+  // empty.
+  if (array_key_exists('value', $item) and empty($item['value'])){
+    return TRUE;
   }
 
-  // Otherwise, the field is empty.
-  return TRUE;
+  // Otherwise, the field is not empty.
+  return FALSE;
 }
 
 /**

+ 1 - 1
tripal_chado/includes/TripalFields/sbo__relationship/sbo__relationship_formatter.inc

@@ -104,7 +104,7 @@ class sbo__relationship_formatter extends ChadoFieldFormatter {
 
     // Build the pager
     $items_per_page = array_key_exists('items_per_page', $this->instance['settings']) ? $this->instance['settings']['items_per_page'] : 10;
-    $total_records = count($items);
+    $total_records = count($rows);
     $total_pages = (int) ($total_records / $items_per_page) + 1;
     $pelement = 0; //$this->getPagerElementID();
     $current_page = pager_default_initialize($total_records, $items_per_page, $pelement);