Procházet zdrojové kódy

Fixed chado_linker_cvterm_adder and chado_linker_cvterm

Chun-Huai Cheng před 8 roky
rodič
revize
a267f7cf2c

+ 9 - 9
tripal_chado/includes/TripalFields/chado_base__dbxref_id.inc

@@ -68,11 +68,11 @@ class chado_base__dbxref_id extends TripalField {
 
 
     // Check $form_state['values'] to see if an AJAX call set the values.
     // Check $form_state['values'] to see if an AJAX call set the values.
     if (array_key_exists('values', $form_state)) {
     if (array_key_exists('values', $form_state)) {
-      $fk_val = $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column];
-      $db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
-      $accession = $form_state['values'][$field_name]['und'][$delta]['accession'];
-      $version = $form_state['values'][$field_name]['und'][$delta]['version'];
-      $description = $form_state['values'][$field_name]['und'][$delta]['description'];
+      $fk_val = isset($form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column]) ? $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column] : '';
+      $db_id = isset($form_state['values'][$field_name]['und'][$delta]['db_id']) ? $form_state['values'][$field_name]['und'][$delta]['db_id'] : '';
+      $accession = isset($form_state['values'][$field_name]['und'][$delta]['accession']) ? $form_state['values'][$field_name]['und'][$delta]['accession'] : '';
+      $version = isset($form_state['values'][$field_name]['und'][$delta]['version']) ? $form_state['values'][$field_name]['und'][$delta]['version'] : '';
+      $description = isset($form_state['values'][$field_name]['und'][$delta]['description']) ? $form_state['values'][$field_name]['und'][$delta]['description'] : '';
     }
     }
 
 
     $schema = chado_get_schema('dbxref');
     $schema = chado_get_schema('dbxref');
@@ -213,10 +213,10 @@ class chado_base__dbxref_id extends TripalField {
     $field_table = $this->field['settings']['chado_table'];
     $field_table = $this->field['settings']['chado_table'];
     $field_column = $this->field['settings']['chado_column'];
     $field_column = $this->field['settings']['chado_column'];
 
 
-    $fk_val = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $field_column];
-    $db_id = $form_state['values'][$field_name][$langcode][$delta]['db_id'];
-    $accession = $form_state['values'][$field_name][$langcode][$delta]['accession'];
-    $version = $form_state['values'][$field_name][$langcode][$delta]['version'];
+    $fk_val = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $field_column]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__' . $field_column] : '';
+    $db_id = isset($form_state['values'][$field_name][$langcode][$delta]['db_id']) ? $form_state['values'][$field_name][$langcode][$delta]['db_id'] : '';
+    $accession = isset($form_state['values'][$field_name][$langcode][$delta]['accession']) ? $form_state['values'][$field_name][$langcode][$delta]['accession'] : '';
+    $version = isset($form_state['values'][$field_name][$langcode][$delta]['version']) ? $form_state['values'][$field_name][$langcode][$delta]['version'] : '';
 
 
     // If user did not select a database, we want to remove dbxref_id from the
     // If user did not select a database, we want to remove dbxref_id from the
     // field.
     // field.

+ 1 - 1
tripal_chado/includes/TripalFields/chado_feature__md5checksum.inc

@@ -77,7 +77,7 @@ class chado_feature__md5checksum  extends TripalField {
     $field_column = $field['settings']['chado_column'];
     $field_column = $field['settings']['chado_column'];
 
 
     // Get the residues so we can calculate teh length.
     // Get the residues so we can calculate teh length.
-    $residues = $form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues'];
+    $residues = isset($form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues']) ? $form_state['values']['feature__residues'][$langcode][0]['chado-feature__residues'] : '';
 
 
     if ($residues) {
     if ($residues) {
       // Remove spaces and new lines from the residues string.
       // Remove spaces and new lines from the residues string.

+ 1 - 1
tripal_chado/includes/TripalFields/chado_feature__residues.inc

@@ -106,7 +106,7 @@ class chado_feature__residues extends TripalField {
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
 
 
     // Remove any white spaces.
     // Remove any white spaces.
-    $residues = $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'];
+    $residues = isset($form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'] : '';
     if ($residues) {
     if ($residues) {
       $residues = preg_replace('/\s/', '', $residues);
       $residues = preg_replace('/\s/', '', $residues);
       $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'] = $residues;
       $form_state['values'][$field_name][$langcode][$delta]['chado-feature__residues'] = $residues;

+ 3 - 3
tripal_chado/includes/TripalFields/chado_linker__contact.inc

@@ -164,9 +164,9 @@ class chado_linker__contact extends TripalField {
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
 
 
     // Get the field values.
     // Get the field values.
-    $fkey_value = $form_state['values'][$field_name][$langcode][$delta]['value'];
-    $contact_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id'];
-    $name = $form_state['values'][$field_name][$langcode][$delta]['name'];
+    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['value']) ? $form_state['values'][$field_name][$langcode][$delta]['value'] : '';
+    $contact_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__contact_id'] : '';
+    $name = isset($form_state['values'][$field_name][$langcode][$delta]['name']) ? $form_state['values'][$field_name][$langcode][$delta]['name'] : '';
 
 
     // If the user provided a name then we want to set the foreign key
     // If the user provided a name then we want to set the foreign key
     // value to be the chado_record_id
     // value to be the chado_record_id

+ 16 - 33
tripal_chado/includes/TripalFields/chado_linker__cvterm.inc

@@ -89,8 +89,6 @@ class chado_linker__cvterm extends TripalField {
   public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
   public function widgetForm(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
     parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
     parent::widgetForm($widget, $form, $form_state, $langcode, $items, $delta, $element);
 
 
-
-    $entity = $form['#entity'];
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
 
 
     $matches = array();
     $matches = array();
@@ -123,7 +121,6 @@ class chado_linker__cvterm extends TripalField {
     // array.  This happens when editing an existing record.
     // array.  This happens when editing an existing record.
     if (array_key_exists($delta, $items)) {
     if (array_key_exists($delta, $items)) {
       $record_id = $items[$delta]['value'];
       $record_id = $items[$delta]['value'];
-      $fkey_value = $items[$delta]['chado-' . $table_name . '__' . $fkey];
       $cvterm_name = $items[$delta]['cvterm__name'];
       $cvterm_name = $items[$delta]['cvterm__name'];
       $is_not = $items[$delta]['chado-' . $table_name . '__is_not'];
       $is_not = $items[$delta]['chado-' . $table_name . '__is_not'];
       $cvterm_id = $items[$delta]['chado-' . $table_name . '__cvterm_id'];
       $cvterm_id = $items[$delta]['chado-' . $table_name . '__cvterm_id'];
@@ -147,14 +144,13 @@ class chado_linker__cvterm extends TripalField {
 
 
     $widget['#table_name'] = $chado_table;
     $widget['#table_name'] = $chado_table;
     $widget['#fkey_field'] = $fkey;
     $widget['#fkey_field'] = $fkey;
-    $widget['#element_validate'] = array('chado_linker__cvterm_widget_validate');
     $widget['#theme'] = 'chado_linker__cvterm_widget';
     $widget['#theme'] = 'chado_linker__cvterm_widget';
     $widget['#prefix'] =  "<span id='$table_name-$delta'>";
     $widget['#prefix'] =  "<span id='$table_name-$delta'>";
     $widget['#suffix'] =  "</span>";
     $widget['#suffix'] =  "</span>";
 
 
     $widget['value'] = array(
     $widget['value'] = array(
       '#type' => 'value',
       '#type' => 'value',
-      '#value' => $items[$delta]['value'],
+      '#value' => key_exists($delta, $items) ? $items[$delta]['value'] : '',
     );
     );
 
 
     $widget['chado-' . $table_name . '__' . $pkey] = array(
     $widget['chado-' . $table_name . '__' . $pkey] = array(
@@ -206,7 +202,13 @@ class chado_linker__cvterm extends TripalField {
   public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
   public function widgetFormSubmit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
 
 
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
-    $field_type = $this->field['type'];
+    $table_name = $this->field['settings']['chado_table'];
+    $schema = chado_get_schema($table_name);
+    $pkey = $schema['primary key'][0];
+    $base_table = $this->field['settings']['base_table'];
+    $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
+    $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
+
 
 
     // If the form ID is field_ui_field_edit_form, then the user is editing the
     // If the form ID is field_ui_field_edit_form, then the user is editing the
     // field's values in the manage fields form of Drupal.  We don't want
     // field's values in the manage fields form of Drupal.  We don't want
@@ -215,35 +217,16 @@ class chado_linker__cvterm extends TripalField {
       return;
       return;
     }
     }
 
 
-    // Get the field values.
-    //   $cvterm_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $table_name . '__cvterm_id');
-    //   $cv_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $table_name . '--cvterm__cv_id--cv__cv_id');
-    //   $cvterm_name = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $table_name . '--cvterm__name');
-    //   $cvterm_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $table_name . '__cvterm_id');
-    //   $pub_id = tripal_chado_get_field_form_values($field_name, $form_state, $delta, $table_name . '__pub_id');
-
     // If the user provided a cv_id and a name then we want to set the
     // If the user provided a cv_id and a name then we want to set the
     // foreign key value to be the chado_record_idd
     // foreign key value to be the chado_record_idd
-    if ($cvterm_name) {
+    $cvterm_name = isset($form_state['values'][$field_name][$langcode][$delta]['cvterm__name']) ? $form_state['values'][$field_name][$langcode][$delta]['cvterm__name'] : '';
 
 
-      $fkey_value = $element['#entity']->chado_record_id;
-      tripal_chado_set_field_form_values($field_name, $form_state, $fkey_value, $delta, $table_name . '__' . $fkey);
-
-      // Get the cvterm ID. If one is not available because it's a newly added
-      // record, then we need to retrieve it and set the form element.
-      if (!$cvterm_id) {
-        $cvterm = tripal_get_cvterm(array('cv_id' => $cv_id, 'name' => $cvterm_name));
-        tripal_chado_set_field_form_values($field_name, $form_state, $cvterm->cvterm_id, $delta, $table_name . '__cvterm_id');
-      }
-
-      if (!$pub_id) {
-        $pub = chado_generate_var('pub', array('uniquename' => 'null'));
-        tripal_chado_set_field_form_values($field_name, $form_state, $pub->pub_id, $delta, $table_name . '__pub_id');
-      }
+    if (!$cvterm_name) {
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__cvterm_id'] = '';
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $lfkey_field] = '';
     }
     }
     else {
     else {
-      // If the $cv_id and name are not set, then remove the linker FK value to the base table.
-      tripal_chado_set_field_form_values($field_name, $form_state, '', $delta, $table_name . '__' . $fkey);
+      $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] = 1;
     }
     }
   }
   }
 
 
@@ -252,12 +235,11 @@ class chado_linker__cvterm extends TripalField {
    */
    */
   public function load($entity, $details = array()) {
   public function load($entity, $details = array()) {
 
 
-    $record = $details['record'];
-
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
     $field_type = $this->field['type'];
     $field_type = $this->field['type'];
     $field_table = $this->field['settings']['chado_table'];
     $field_table = $this->field['settings']['chado_table'];
     $field_column = $this->field['settings']['chado_column'];
     $field_column = $this->field['settings']['chado_column'];
+    $base_table = $this->field['settings']['base_table'];
 
 
     $matches = array();
     $matches = array();
     preg_match('/(.*?)__(\d+)/', $field_name, $matches);
     preg_match('/(.*?)__(\d+)/', $field_name, $matches);
@@ -271,6 +253,7 @@ class chado_linker__cvterm extends TripalField {
     $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
     $fkey_rcolumn = $schema['foreign keys'][$base_table]['columns'][$fkey_lcolumn];
 
 
     // Set some defaults for the empty record.
     // Set some defaults for the empty record.
+    $chado_record = $entity->chado_record;
     $entity->{$field_name}['und'][0] = array(
     $entity->{$field_name}['und'][0] = array(
       'value' => '',
       'value' => '',
       'chado-' . $field_table . '__' . $fkey_lcolumn => '',
       'chado-' . $field_table . '__' . $fkey_lcolumn => '',
@@ -295,7 +278,7 @@ class chado_linker__cvterm extends TripalField {
     // Get the annotations associated with this base record for this fields type.
     // Get the annotations associated with this base record for this fields type.
     $columns = array('*');
     $columns = array('*');
     $match = array(
     $match = array(
-      $fkey_lcolumn => $record->$fkey_rcolumn,
+      $fkey_lcolumn => $chado_record->$fkey_rcolumn,
       'cvterm_id' => array(
       'cvterm_id' => array(
         'cv_id' => $cv_id,
         'cv_id' => $cv_id,
       ),
       ),

+ 42 - 14
tripal_chado/includes/TripalFields/chado_linker__cvterm_adder.inc

@@ -48,7 +48,7 @@ class chado_linker__cvterm_adder extends TripalField {
     $widget['cvterm_class_adder_instructions'] = array(
     $widget['cvterm_class_adder_instructions'] = array(
       '#type' => 'item',
       '#type' => 'item',
       '#markup' => t('You may add annotation types to this form by
       '#markup' => t('You may add annotation types to this form by
-          providing a vocabulary name in the field below
+          providing a vocabulary name in the field above
           and clicking the "Add Annotation Type" button.  This will add a
           and clicking the "Add Annotation Type" button.  This will add a
           new field to the form above for the vocabulary you entered which
           new field to the form above for the vocabulary you entered which
           will allow users to associate terms from that vocabulary to
           will allow users to associate terms from that vocabulary to
@@ -82,6 +82,35 @@ class chado_linker__cvterm_adder extends TripalField {
     );
     );
   }
   }
 
 
+  /**
+   * @see TripalField::widgetFormValidate()
+   */
+  public function widgetFormValidate($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
+  
+    if (array_key_exists('triggering_element', $form_state) and
+        $form_state['triggering_element']['#name'] == 'cvterm_class_adder_button') {
+          $this_field = $this->field;
+          $field_name = $this_field['field_name'];
+          $bundle = $entity->bundle;
+          
+          // Get the base table name from the field annotations.
+          $base_table = $entity->chado_table;
+          $cvterm_class_adder = $form_state['values'][$base_table . '_cvterm'][$langcode][$delta]['value'];
+          $cv = chado_generate_var('cv', array('cv_id' => $cvterm_class_adder));
+          
+          // Make sure a valid vocabulary is selected
+          if (!$cv) {
+            form_set_error("$field_name][$langcode][$delta][value", "Please select a vocabulary.");
+          }
+          else {
+            // Make sure this vocabulary doesn't already have a field
+            if (key_exists($field_name . '__' . $cv->cv_id, $form_state['values'])) {
+              form_set_error("$field_name][$langcode][$delta][wrapper][terms_name", "Field for this vocabulary already exists. Please select another vocabulary.");
+            }
+          }
+        }
+  }
+  
   /**
   /**
    * @see TripalField::widgetFormSubmit()
    * @see TripalField::widgetFormSubmit()
    */
    */
@@ -92,20 +121,19 @@ class chado_linker__cvterm_adder extends TripalField {
         $form_state['triggering_element']['#name'] == 'cvterm_class_adder_button') {
         $form_state['triggering_element']['#name'] == 'cvterm_class_adder_button') {
 
 
           $form_state['rebuild'] = TRUE;
           $form_state['rebuild'] = TRUE;
-          $field_name = $element['#field_name'];
-          $entity_type = $element['#entity']->type;
-          $bundle = $element['#entity']->bundle;
-
+          $this_field = $this->field;
+          $field_name = $this_field['field_name'];
+          $bundle = $entity->bundle;
+          
           // Get the base table name from the field annotations.
           // Get the base table name from the field annotations.
-          $field = field_info_field($field_name);
-          $base_table = $field['settings']['base_table'];
+          $base_table = $entity->chado_table;
+          $cvterm_class_adder = $form_state['values'][$base_table . '_cvterm'][$langcode][$delta]['value'];
 
 
           // Get the vocabulary.
           // Get the vocabulary.
           //$cvterm_class_adder = tripal_chado_get_field_form_values($field_name, $form_state);
           //$cvterm_class_adder = tripal_chado_get_field_form_values($field_name, $form_state);
           $cv = chado_generate_var('cv', array('cv_id' => $cvterm_class_adder));
           $cv = chado_generate_var('cv', array('cv_id' => $cvterm_class_adder));
 
 
           if (!$cv) {
           if (!$cv) {
-            form_set_error(implode('][', $element ['#parents']) . '][value', t("Please select a vocabulary."));
             return;
             return;
           }
           }
 
 
@@ -120,8 +148,8 @@ class chado_linker__cvterm_adder extends TripalField {
           $field = field_info_field('cvterm');
           $field = field_info_field('cvterm');
           if (!$field) {
           if (!$field) {
             $create_info = array(
             $create_info = array(
-              'field_name' => 'cvterm',
-              'type' => 'tripal_chado_cvterm_widget',
+              'field_name' => $type_field_name,
+              'type' => 'chado_linker__cvterm',
               'cardinality' => FIELD_CARDINALITY_UNLIMITED,
               'cardinality' => FIELD_CARDINALITY_UNLIMITED,
               'locked' => FALSE,
               'locked' => FALSE,
               'storage' => array(
               'storage' => array(
@@ -141,15 +169,15 @@ class chado_linker__cvterm_adder extends TripalField {
               !array_key_exists('TripalEntity', $field['bundles']) or
               !array_key_exists('TripalEntity', $field['bundles']) or
               !in_array($bundle_name, $field['bundles']['TripalEntity'])) {
               !in_array($bundle_name, $field['bundles']['TripalEntity'])) {
                 $createInstanceInfo = array(
                 $createInstanceInfo = array(
-                  'field_name' => 'cvtmerm',
+                  'field_name' => $type_field_name,
                   'entity_type' => 'TripalEntity',
                   'entity_type' => 'TripalEntity',
-                  'bundle' => $this->bundle->name,
+                  'bundle' => $bundle,
                   'label' => ucfirst(preg_replace('/_/', ' ', $cv->name)),
                   'label' => ucfirst(preg_replace('/_/', ' ', $cv->name)),
                   'description' => "Annotations from the $cv->name vocabulary",
                   'description' => "Annotations from the $cv->name vocabulary",
                   'required' => FALSE,
                   'required' => FALSE,
                   'settings' => array(),
                   'settings' => array(),
                   'widget' => array(
                   'widget' => array(
-                    'type' => 'tripal_chado_cvterm_widget',
+                    'type' => 'chado_linker__cvterm_widget',
                     'settings' => array(
                     'settings' => array(
                       'display_label' => 1,
                       'display_label' => 1,
                     ),
                     ),
@@ -157,7 +185,7 @@ class chado_linker__cvterm_adder extends TripalField {
                   'display' => array(
                   'display' => array(
                     'default' => array(
                     'default' => array(
                       'label' => 'above',
                       'label' => 'above',
-                      'type' => 'tripal_chado_cvterm_formatter',
+                      'type' => 'chado_linker__cvterm_formatter',
                       'settings' => array(),
                       'settings' => array(),
                     ),
                     ),
                   ),
                   ),

+ 5 - 5
tripal_chado/includes/TripalFields/chado_linker__dbxref.inc

@@ -268,11 +268,11 @@ class chado_linker__dbxref extends TripalField {
     $fkey = $fkeys[0];
     $fkey = $fkeys[0];
 
 
     // Get the field values.
     // Get the field values.
-    $dbxref_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id'];
-    $db_id = $form_state['values'][$field_name][$langcode][$delta]['db_id'];
-    $accession = $form_state['values'][$field_name][$langcode][$delta]['accession'];
-    $version = $form_state['values'][$field_name][$langcode][$delta]['version'];
-    $description = $form_state['values'][$field_name][$langcode][$delta]['description'];
+    $dbxref_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $field_table . '__dbxref_id'] : '';
+    $db_id = isset($form_state['values'][$field_name][$langcode][$delta]['db_id']) ? $form_state['values'][$field_name][$langcode][$delta]['db_id'] : '';
+    $accession = isset($form_state['values'][$field_name][$langcode][$delta]['accession']) ? $form_state['values'][$field_name][$langcode][$delta]['accession'] : '';
+    $version = isset($form_state['values'][$field_name][$langcode][$delta]['version']) ? $form_state['values'][$field_name][$langcode][$delta]['version'] : '';
+    $description = isset($form_state['values'][$field_name][$langcode][$delta]['description']) ? $form_state['values'][$field_name][$langcode][$delta]['description'] : '';
 
 
     // If the dbxref_id does not match the db_id + accession then the user
     // If the dbxref_id does not match the db_id + accession then the user
     // has selected a new dbxref record and we need to update the hidden
     // has selected a new dbxref record and we need to update the hidden

+ 1 - 1
tripal_chado/includes/TripalFields/chado_linker__prop.inc

@@ -131,7 +131,7 @@ class chado_linker__prop extends TripalField {
     $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
     $lfkey_field = key($schema['foreign keys'][$base_table]['columns']);
     $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
     $rfkey_field = $schema['foreign keys'][$base_table]['columns'][$lfkey_field];
 
 
-    $prop_value = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__value'];
+    $prop_value = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__value']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__value'] : '';
 
 
     // If the user removed the contact from the contact_name field
     // If the user removed the contact from the contact_name field
     // then we want to clear out the rest of the hidden values.
     // then we want to clear out the rest of the hidden values.

+ 1 - 1
tripal_chado/includes/TripalFields/chado_linker__prop_adder.inc

@@ -58,7 +58,7 @@ class chado_linker__prop_adder extends TripalField {
           of this type.'),
           of this type.'),
     );
     );
 
 
-    $term_name = array_key_exists('values', $form_state) ? $form_state['values'][$field_name]['und'][0]['wrapper']['term_name'] : '';
+    $term_name = isset($form_state['values'][$field_name]['und'][0]['wrapper']['term_name']) ? $form_state['values'][$field_name]['und'][0]['wrapper']['term_name'] : '';
 
 
     // Drupal's vertical feild set is a bit quirky in that we can't just
     // Drupal's vertical feild set is a bit quirky in that we can't just
     // add a prefix and suffix to the weidget.  If we do, then the
     // add a prefix and suffix to the weidget.  If we do, then the

+ 3 - 3
tripal_chado/includes/TripalFields/chado_linker__pub.inc

@@ -141,9 +141,9 @@ class chado_linker__pub extends TripalField {
     $field_name = $this->field['field_name'];
     $field_name = $this->field['field_name'];
 
 
     // Get the field values.
     // Get the field values.
-    $fkey_value = $form_state['values'][$field_name][$langcode][$delta]['value'];
-    $pub_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'];
-    $uname = $form_state['values'][$field_name][$langcode][$delta]['uniquename'];
+    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['value']) ? $form_state['values'][$field_name][$langcode][$delta]['value'] : '';
+    $pub_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] : '';
+    $uname = isset($form_state['values'][$field_name][$langcode][$delta]['uniquename']) ? $form_state['values'][$field_name][$langcode][$delta]['uniquename'] : '';
 
 
     // If the user provided a uniquename then we want to set the foreign key
     // If the user provided a uniquename then we want to set the foreign key
     // value to be the chado_record_id
     // value to be the chado_record_id

+ 8 - 8
tripal_chado/includes/TripalFields/chado_linker__synonym.inc

@@ -219,14 +219,14 @@ class chado_linker__synonym extends TripalField {
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
     $fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
     $fkey = $fkeys[0];
     $fkey = $fkeys[0];
 
 
-    $record_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey];
-    $fkey_value = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey];
-    $synonym_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id'];
-    $pub_id = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'];
-    $is_current = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current'];
-    $is_internal = $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal'];
-    $syn_name = $form_state['values'][$field_name][$langcode][$delta]['name'];
-    $syn_type = $form_state['values'][$field_name][$langcode][$delta]['type_id'];
+    $record_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $pkey] : '';
+    $fkey_value = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey]) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__' . $fkey] : '';
+    $synonym_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__synonym_id'] : '';
+    $pub_id = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__pub_id'] : '';
+    $is_current = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_current'] : '';
+    $is_internal = isset($form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal']) ? $form_state['values'][$field_name][$langcode][$delta]['chado-' . $table_name . '__is_internal'] : '';
+    $syn_name = isset($form_state['values'][$field_name][$langcode][$delta]['name']) ? $form_state['values'][$field_name][$langcode][$delta]['name'] : '';
+    $syn_type = isset($form_state['values'][$field_name][$langcode][$delta]['type_id']) ? $form_state['values'][$field_name][$langcode][$delta]['type_id'] : '';
 
 
     // If the user provided a $syn_name and a $syn_type then we want to set
     // If the user provided a $syn_name and a $syn_type then we want to set
     // the foreign key value to be the chado_record_id.
     // the foreign key value to be the chado_record_id.