Эх сурвалжийг харах

added settingsFormValidate function to TripalField

Stephen Ficklin 8 жил өмнө
parent
commit
f2084464ff

+ 11 - 0
tripal/includes/TripalField.inc

@@ -620,9 +620,20 @@ class TripalField {
 //       '#tree' => TRUE,
 //     );
 
+    $element['#field'] = $field;
+    $element['#instance'] = $instance;
+    $element['#validate'][] = "[module_name]_field_settings_form_validate";
 
     return $element;
   }
+  /**
+   *
+   * @param unknown $form
+   * @param unknown $form_state
+   */
+  public static function settingsFormValidate($form, &$form_state) {
+
+  }
 
   /**
    * Describes this fields "data tables" to Views.

+ 25 - 1
tripal_chado/includes/fields/chado_linker__relationship.inc

@@ -10,7 +10,9 @@ class chado_linker__relationship extends TripalField {
       'description' => t('Relationships between records.'),
       'default_widget' => 'chado_linker__relationship_widget',
       'default_formatter' => 'chado_linker__relationship_formatter',
-      'settings' => array(),
+      'settings' => array(
+        # Put settings here that Drupal will save automatically.
+      ),
       'storage' => array(
         'type' => 'field_chado_storage',
         'module' => 'tripal_chado',
@@ -18,6 +20,7 @@ class chado_linker__relationship extends TripalField {
       ),
     );
   }
+
   /**
    * @see TripalField::can_attach()
    */
@@ -850,6 +853,27 @@ class chado_linker__relationship extends TripalField {
 
     return $verb;
   }
+
+  /**
+   *
+   * @param unknown $field
+   * @param unknown $instance
+   * @param unknown $has_data
+   */
+  public static function settingsForm($field, $instance, $has_data) {
+    $element = parent::settingsForm($field, $instance, $has_data);
+
+    // Rest of the code goes here.
+  }
+  /**
+   *
+   * @param unknown $field
+   * @param unknown $instance
+   * @param unknown $has_data
+   */
+  public static function settingsFormValidate($field, $instance, $has_data) {
+
+  }
 }
 
 /**

+ 18 - 0
tripal_chado/includes/tripal_chado.fields.inc

@@ -530,6 +530,24 @@ function tripal_chado_field_settings_form($field, $instance, $has_data) {
   }
   return $form;
 }
+
+/**
+ * Implements hook_field_settings_form_validate().
+ *
+ * This is not an actual Drpual hook, but rather a Tripal created hook
+ * to alow the TripalField objects to have a settingsFormValidate() member
+ * function.
+ */
+function tripal_chado_field_settings_form_valiate($form, &$form_state) {
+  $field = $form['#field'];
+  $instance = $form['#instance'];
+  $field_type = $field['type'];
+  module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
+  if (class_exists($field_type)) {
+    $form = $field_type::settingsFormValidate($field, $instance, $form, $form_state);
+  }
+}
+
 /**
  * Implements hook_field_formatter_settings_summary().
  */