浏览代码

Fixed issue with hidden fields

Stephen Ficklin 7 年之前
父节点
当前提交
49f6fc2bea
共有 3 个文件被更改,包括 17 次插入16 次删除
  1. 0 2
      tripal/includes/tripal.fields.inc
  2. 8 7
      tripal/tripal.module
  3. 9 7
      tripal_ds/tripal_ds.module

+ 0 - 2
tripal/includes/tripal.fields.inc

@@ -856,8 +856,6 @@ function tripal_form_field_ui_display_overview_form_alter(&$form, &$form_state,
   }
 }
 
-
-
 /**
  * Implements hook_field_is_empty().
  */

+ 8 - 7
tripal/tripal.module

@@ -1011,14 +1011,15 @@ function tripal_field_display_alter(&$display, $context){
   $field_name = $context['field']['field_name'];
   $bundle = $context['entity']->bundle;
   $bundle_info = tripal_load_bundle_entity(array('name' => $bundle));
-  $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, '');
+  $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, 'hide');
 
   if($hide_variable == 'hide'){
-    $field = field_get_items('TripalEntity', $context['entity'], $field_name);
-    if($field) {
-      if(tripal_field_is_empty($field, $field)) {
-            // Stop the right rail element from rendering.
-            drupal_add_css('.'.$field_name.' {display:none;}', 'inline');
+    $item = field_get_items('TripalEntity', $context['entity'], $field_name);
+    if($item) {
+      $field = field_info_field($field_name);
+      if(tripal_field_is_empty($item[0], $field)) {
+        // Stop the right rail element from rendering.
+        drupal_add_css('.'.$field_name.' {display:none;}', 'inline');
       }
     }
   }
@@ -1044,7 +1045,7 @@ function tripal_field_group_table_rows_alter(&$element, &$children) {
 
       // If the hide empty variable is turned on then remove fields from
       // the field group.
-      $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, '');
+      $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, 'hide');
       if($hide_variable == 'hide'){
         $items = $element[$child]['#items'];
         // Case #1: there are no items.

+ 9 - 7
tripal_ds/tripal_ds.module

@@ -436,12 +436,13 @@ function tripal_ds_field_display_alter(&$display, $context){
   $field_name = $context['field']['field_name'];
   $bundle = $context['entity']->bundle;
   $bundle_info = tripal_load_bundle_entity(array('name' => $bundle));
-  $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, '');
+  $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, 'hide');
 
   if ($field_name && ($hide_variable == 'hide')) {
-    $field = field_get_items('TripalEntity', $context['entity'], $field_name);
-    if ($field) {
-      if (tripal_field_is_empty($field, $field)) {
+    $item = field_get_items('TripalEntity', $context['entity'], $field_name);
+    $field = field_info_field($field_name);
+    if ($item) {
+      if (tripal_field_is_empty($item[0], $field)) {
         $parent_field_info = tripal_ds_find_field_group_parent($field_name, 'TripalEntity', $bundle, $context);
         if (!empty($parent_field_info)) {
           foreach ($parent_field_info as $parent_key => $parent_field){
@@ -489,8 +490,9 @@ function tripal_ds_find_field_group_parent($field_name, $entity_type, $bundle, $
       if (count($children) > 1) {
         foreach ($children as $kids => $child) {
           // Now check if each child if empty.
-          $field = field_get_items('TripalEntity', $context['entity'], $child);
-          if(!tripal_field_is_empty($field, $field)){
+          $item = field_get_items('TripalEntity', $context['entity'], $child);
+          $field = field_info_fild($child);
+          if(!tripal_field_is_empty($item[0], $field)){
             //If any of the fields are not empty do not add the parent.
             break 2;
           }
@@ -498,7 +500,7 @@ function tripal_ds_find_field_group_parent($field_name, $entity_type, $bundle, $
             continue;
           }
         }
-      $field_groups_to_hide[$increment] = $field_group->group_name;
+        $field_groups_to_hide[$increment] = $field_group->group_name;
       }
       elseif($children[0] == $field_name) {
         $field_groups_to_hide[$increment] = $field_group->group_name;