Browse Source

Library: added dbxref to node form

Lacey Sanderson 11 years ago
parent
commit
1faa23a68a
1 changed files with 28 additions and 1 deletions
  1. 28 1
      tripal_library/includes/tripal_library.chado_node.inc

+ 28 - 1
tripal_library/includes/tripal_library.chado_node.inc

@@ -79,7 +79,7 @@ function chado_library_form($node, &$form_state) {
   }
   // if we are re constructing the form from a failed validation or ajax callback
   // then use the $form_state['values'] values
-  if (array_key_exists('values', $form_state)) {
+  if (array_key_exists('values', $form_state) and isset($form_state['values']['title'])) {
     $title        = $form_state['values']['title'];
     $uniquename   = $form_state['values']['uniquename'];
     $library_type = $form_state['values']['library_type'];
@@ -189,6 +189,16 @@ function chado_library_form($node, &$form_state) {
   // Adds the form elements to your current form
   chado_node_properties_form($form, $form_state, $details);
 
+  // ADDITIONAL DBXREFS FORM
+  //---------------------------------------------
+  $details = array(
+    'linking_table' => 'library_dbxref',  // the name of the _dbxref table
+    'base_foreign_key' => 'library_id',   // the name of the key in your base chado table
+    'base_key_value' => $library_id       // the value of library_id for this record
+  );
+  // Adds the form elements to your current form
+  chado_node_additional_dbxrefs_form($form, $form_state, $details);
+
   return $form;
 }
 /**
@@ -267,6 +277,14 @@ function chado_library_insert($node) {
     );
     chado_node_properties_form_update_properties($node, $details, $properties);
 
+    // * Additional DBxrefs Form *
+    $details = array(
+      'linking_table' => 'library_dbxref',   // the name of your _dbxref table
+      'foreignkey_name' => 'library_id',     // the name of the key in your base table
+      'foreignkey_value' => $library_id      // the value of the library_id key
+    );
+    chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details);
+
   }
   else {
     $library_id = $node->library_id;
@@ -325,6 +343,15 @@ function chado_library_update($node) {
     'foreignkey_value' => $library_id    // the value of the library_id key
   );
   chado_node_properties_form_update_properties($node, $details, $properties);
+
+  // * Additional DBxrefs Form *
+  $details = array(
+    'linking_table' => 'library_dbxref',   // the name of your _dbxref table
+    'foreignkey_name' => 'library_id',     // the name of the key in your base table
+    'foreignkey_value' => $library_id      // the value of the library_id key
+  );
+  chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details);
+
 }
 /**
  *  When a node is requested by the user this function is called to allow us