فهرست منبع

Added settingsFormValidate()

Chun-Huai Cheng 8 سال پیش
والد
کامیت
324f673fba

+ 2 - 2
tripal/includes/TripalField.inc

@@ -619,10 +619,10 @@ class TripalField {
 //       '#collapsible' => TRUE,
 //       '#tree' => TRUE,
 //     );
-
+    $module = $field['module'];
     $element['#field'] = $field;
     $element['#instance'] = $instance;
-    $element['#validate'][] = "[module_name]_field_settings_form_validate";
+    $element['#element_validate'][] = $module . '_field_settings_form_validate';
 
     return $element;
   }

+ 3 - 9
tripal_chado/includes/fields/chado_linker__relationship.inc

@@ -11,7 +11,7 @@ class chado_linker__relationship extends TripalField {
       'default_widget' => 'chado_linker__relationship_widget',
       'default_formatter' => 'chado_linker__relationship_formatter',
       'settings' => array(
-        # Put settings here that Drupal will save automatically.
+        'relationship_types' => ''
       ),
       'storage' => array(
         'type' => 'field_chado_storage',
@@ -869,12 +869,10 @@ class chado_linker__relationship extends TripalField {
         following value is set.'
     );
     
-    $terms = variable_get('chado_linker_relationship_types');
-    $element['term_list'] = array(
+    $element['relationship_types'] = array(
       '#type' => 'textarea',
       '#title' => 'Relationship Types',
       '#description' => 'Provide terms separated by a new line',
-      '#default_value' => $terms,
     );
   
     // Add in the semantic web fields.
@@ -891,14 +889,10 @@ class chado_linker__relationship extends TripalField {
    * @param unknown $has_data
    */
   public static function settingsFormValidate($form, &$form_state) {
-
+    //dpm($form);dpm($form_state);
   }
 }
 
-  function settingsFormValidate($field, $instance, $has_data) {
-  dpm($field);
-  }
-
 /**
  * Theme function for the chado_linker__relationship_widget.
  */

+ 3 - 2
tripal_chado/includes/tripal_chado.fields.inc

@@ -538,7 +538,7 @@ function tripal_chado_field_settings_form($field, $instance, $has_data) {
  * to alow the TripalField objects to have a settingsFormValidate() member
  * function.
  */
-function tripal_chado_field_settings_form_valiate($form, &$form_state) {
+function tripal_chado_field_settings_form_validate($form, &$form_state) {
   $field = $form['#field'];
   $instance = $form['#instance'];
   $field_type = $field['type'];
@@ -656,7 +656,8 @@ function tripal_chado_field_validate($entity_type, $entity, $field, $instance,
   $field_type = $field['type'];
   module_load_include('inc', 'tripal_chado', 'includes/fields/' . $field_type);
   if (class_exists($field_type)) {
-    $field_obj = new $field_type($entity_type, $entity->bundle);
+    $bundle = isset($entity->bundle) ? $entity->bundle : NULL;
+    $field_obj = new $field_type($entity_type, $bundle);
     $form = $field_obj::widgetFormValidate($entity_type, $entity, $field, $instance,
         $langcode, $items, $errors);
   }