Browse Source

Maps: added dbxrefs to node form and fixed small bug in properties tpl

Lacey Sanderson 11 years ago
parent
commit
a717e8c35b

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

@@ -73,7 +73,7 @@ function chado_featuremap_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'];
     $description = $form_state['values']['description'];
     $unittype_id = $form_state['values']['unittype_id'];
@@ -138,6 +138,16 @@ function chado_featuremap_form($node, &$form_state) {
   );
   chado_node_properties_form($form, $form_state, $details);
 
+  // ADDITIONAL DBXREFS FORM
+  //---------------------------------------------
+  $details = array(
+    'linking_table' => 'featuremap_dbxref',  // the name of the _dbxref table
+    'base_foreign_key' => 'featuremap_id',   // the name of the key in your base chado table
+    'base_key_value' => $featuremap_id       // the value of featuremap_id for this record
+  );
+  // Adds the form elements to your current form
+  chado_node_additional_dbxrefs_form($form, $form_state, $details);
+
   return $form;
 }
 /**
@@ -296,6 +306,15 @@ function chado_featuremap_insert($node) {
       'foreignkey_value' => $featuremap_id
     );
     chado_node_properties_form_update_properties($node, $details, $properties);
+
+    // * Additional DBxrefs Form *
+    $details = array(
+      'linking_table' => 'featuremap_dbxref',   // the name of your _dbxref table
+      'foreignkey_name' => 'featuremap_id',     // the name of the key in your base table
+      'foreignkey_value' => $featuremap_id      // the value of the featuremap_id key
+    );
+    chado_node_additional_dbxrefs_form_update_dbxrefs($node, $details);
+
   }
   else {
     $featuremap_id = $node->featuremap_id;
@@ -368,6 +387,14 @@ function chado_featuremap_update($node) {
   );
   chado_node_properties_form_update_properties($node, $details, $properties);
 
+  // * Additional DBxrefs Form *
+  $details = array(
+    'linking_table' => 'featuremap_dbxref',   // the name of your _dbxref table
+    'foreignkey_name' => 'featuremap_id',     // the name of the key in your base table
+    'foreignkey_value' => $featuremap_id      // the value of the featuremap_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

+ 7 - 6
tripal_featuremap/theme/tripal_featuremap/tripal_featuremap.properties.tpl.php

@@ -5,18 +5,18 @@ $options = array('return_array' => 1);
 $featuremap = tripal_core_expand_chado_vars($featuremap, 'table', 'featuremapprop', $options);
 $properties = $featuremap->featuremapprop;
 
-if(count($properties) > 0){ 
+if(count($properties) > 0){
   // the $headers array is an array of fields to use as the colum headers.
   // additional documentation can be found here
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $headers = array('Property Name', 'Value');
-  
+
   // the $rows array contains an array of rows where each row is an array
   // of values for each column of the table in that row.  Additional documentation
   // can be found here:
   // https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_table/7
   $rows = array();
-  
+
   foreach ($properties as $property){
     $property = tripal_core_expand_chado_vars($property,'field','featuremapprop.value');
     $rows[] = array(
@@ -24,7 +24,7 @@ if(count($properties) > 0){
       urldecode($property->value)
     );
   }
-   
+
   // the $table array contains the headers and rows array as well as other
   // options for controlling the display of the table.  Additional
   // documentation can be found here:
@@ -40,7 +40,8 @@ if(count($properties) > 0){
     'colgroups' => array(),
     'empty' => '',
   );
-  
+
   // once we have our table array structure defined, we call Drupal's theme_table()
   // function to generate the table.
-  print theme_table($table); 
+  print theme_table($table);
+}