ソースを参照

fix variable declarations and write update

bradfordcondon 6 年 前
コミット
2882ad96f7

+ 6 - 4
tripal_chado/includes/TripalFields/chado_base__text/chado_base__text_widget.inc

@@ -3,11 +3,13 @@
 
 class chado_base__text_widget extends ChadoFieldWidget {
 
-  // The list of field types for which this widget is appropriate.
-  public static $field_types = ['text'];
+  //public static $field_types = ['text'];
 
-  public $default_label;
-  public $widget_type;
+  //This widget should be extended with a label for the text type.
+  //public static $default_label ;
+
+  //This widget should be extended and define a text type.
+  public static $widget_type;
 
 
   /**

+ 3 - 1
tripal_chado/includes/TripalFields/chado_base__text/chado_base__textarea_widget.inc

@@ -2,6 +2,8 @@
 
 class chado_base__textarea_widget extends chado_base__text_widget {
 
-  public $widget_type = 'textarea';
+  public static $widget_type = 'textarea';
   public static $default_label = 'Chado Area Text Field';
+  public static $field_types = ['text'];
+
 }

+ 2 - 1
tripal_chado/includes/TripalFields/chado_base__text/chado_base__textfield_widget.inc

@@ -3,7 +3,8 @@
 
 class chado_base__textfield_widget extends chado_base__text_widget {
 
-  public $widget_type = 'textfield';
+  public static $widget_type = 'textfield';
   public static $default_label = 'Chado Text Field';
+  public static $field_types = ['text'];
 }
 

+ 29 - 1
tripal_chado/tripal_chado.install

@@ -1850,7 +1850,35 @@ function tripal_chado_update_7336() {
       $instance_info['widget']['type'] = 'chado_linker__contact_widget';
       $instance_info['formatter']['type'] = 'chado_linker__contact_widget';
       field_update_instance($instance_info);
-      
+
+    }
+  }
+}
+
+/**
+ * Cusomize default text type widgets linked to chado content.
+ */
+function tripal_chado_update_7337() {
+
+
+  $bundles = field_info_instances('TripalEntity');
+
+  foreach ($bundles as $bundle_name => $fields) {
+    
+    foreach ($fields as $field){
+
+      if ($field['widget']['type'] == 'text_textfield' && isset($field['settings']['base_table'])){
+
+        $field['widget']['type'] = 'chado_base__textfield';
+        field_update_instance($field);
+     }
+
+      if ($field['widget']['type'] == 'text_textarea' && isset($field['settings']['base_table'])){
+
+        $field['widget']['type'] = 'chado_base__textarea';
+        field_update_instance($field);
+      }
     }
   }
 }
+