Browse Source

Ensure content only hidden using ajax when config to hide.

Lacey Sanderson 6 years ago
parent
commit
5c3855bee8
1 changed files with 5 additions and 1 deletions
  1. 5 1
      tripal/includes/tripal.entity.inc

+ 5 - 1
tripal/includes/tripal.entity.inc

@@ -560,6 +560,10 @@ function tripal_ajax_attach_field($id) {
     reset($result);
     $entity = $result[$entity_id];
 
+    // Settings for whether to hide fields for this content type.
+    $bundle_info = tripal_load_bundle_entity(array('name' => $entity->bundle));
+    $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id);
+
     // Get the element render array for this field and turn off the label
     // display. It's already on the page.  We need to get the display from the
     // instance and pass it into the field_view_field. Otherwise it uses the
@@ -567,7 +571,7 @@ function tripal_ajax_attach_field($id) {
     // more investigation.
     $instance = field_info_instance('TripalEntity', $field_name, $entity->bundle);
     $items = field_get_items('TripalEntity', $entity, $field_name);
-    if(count($items) > 0 && tripal_field_is_empty($items[0], $field)) {
+    if($hide_variable && count($items) > 0 && tripal_field_is_empty($items[0], $field)) {
       return drupal_json_output([
         'id' => $id,
         'content' => '',