Procházet zdrojové kódy

Fix for issue for hiding fields that are not for TripalEntity content types

Stephen Ficklin před 7 roky
rodič
revize
d066855b26
1 změnil soubory, kde provedl 7 přidání a 4 odebrání
  1. 7 4
      tripal/tripal.module

+ 7 - 4
tripal/tripal.module

@@ -1005,23 +1005,26 @@ function tripal_html5_file_value($element, $input = FALSE, &$form_state) {
 
 
 /**
- *  Implements hook_field_display_alter().
+ * Implements hook_field_display_alter().
+ *
  * @param $display
  * @param $context
  */
-function tripal_field_display_alter(&$display, $context){
+function tripal_field_display_TripalEntity_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');
 
+  // Hide fields that are empty, but only if the hide_empty_field variable
+  // is set to 'hide' for this bundel.
+  $hide_variable = tripal_get_bundle_variable('hide_empty_field', $bundle_info->id, 'hide');
   if($hide_variable == 'hide'){
     $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');
+        drupal_add_css('.' . $field_name.' {display: none;}', 'inline');
       }
     }
   }