Bläddra i källkod

Adjusted properties of properties form function call

Stephen Ficklin 11 år sedan
förälder
incheckning
5c7098b42d

+ 3 - 2
tripal_analysis/includes/tripal_analysis.form.inc

@@ -202,9 +202,10 @@ function chado_analysis_form($node, &$form_state) {
   }
   }
   
   
   $exclude = array();
   $exclude = array();
+  $include = array();
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   $instructions = t('To add additional properties to the drop down. ' . l("Add terms to the analysis_property vocabulary", "admin/tripal/chado/tripal_cv/cvterm/add") . ".");
   tripal_core_properties_form($form, $form_state, 'analysisprop', 'analysis_id', 'analysis_property',
   tripal_core_properties_form($form, $form_state, 'analysisprop', 'analysis_id', 'analysis_property',
-    $properties, $analysis_id, $exclude, $instructions);
+    $properties, $analysis_id, $exclude, $include, $instructions, 'Properties');
 
 
   return $form;
   return $form;
 }
 }
@@ -215,7 +216,7 @@ function chado_analysis_form($node, &$form_state) {
  */
  */
 function chado_analysis_validate($node, $form, &$form_state) {
 function chado_analysis_validate($node, $form, &$form_state) {
   // use the analysis parent to validate the node
   // use the analysis parent to validate the node
-  tripal_analysis_validate($node, $form_state);
+  tripal_analysis_validate($node, $form, $form_state);
 }
 }
 
 
 /**
 /**

+ 5 - 5
tripal_contact/includes/tripal_contact.form.inc

@@ -151,8 +151,9 @@ function chado_contact_form(&$node, $form_state) {
   }
   }
   
   
   $exclude = array('contact_description');
   $exclude = array('contact_description');
+  $include = array();
   tripal_core_properties_form($form, $form_state, 'contactprop', 'contact_id', 'tripal_contact',
   tripal_core_properties_form($form, $form_state, 'contactprop', 'contact_id', 'tripal_contact',
-    $properties, $contact_id, $exclude, '');
+    $properties, $contact_id, $exclude, $include, '', 'Properties');
    
    
   return $form;
   return $form;
 }
 }
@@ -167,7 +168,6 @@ function chado_contact_validate($node, $form, &$form_state) {
   $node->title          = trim($node->title);
   $node->title          = trim($node->title);
   $node->description    = trim($node->description);
   $node->description    = trim($node->description);
  
  
-  
   // if this is a delete then don't validate
   // if this is a delete then don't validate
   if($node->op == 'Delete') {
   if($node->op == 'Delete') {
     return;
     return;
@@ -180,7 +180,7 @@ function chado_contact_validate($node, $form, &$form_state) {
   }
   }
   
   
   // Validating for an update
   // Validating for an update
-  if (!property_exists($node,'nid')) {    
+  if (property_exists($node, 'nid')) {    
     // get the existing node    
     // get the existing node    
     $values = array('contact_id' => $node->contact_id);      
     $values = array('contact_id' => $node->contact_id);      
     $result = tripal_core_chado_select('contact', array('*'), $values);
     $result = tripal_core_chado_select('contact', array('*'), $values);
@@ -191,7 +191,7 @@ function chado_contact_validate($node, $form, &$form_state) {
       $values = array('name' => $node->title);
       $values = array('name' => $node->title);
       $result = tripal_core_chado_select('contact', array('contact_id'), $values);
       $result = tripal_core_chado_select('contact', array('contact_id'), $values);
       if ($result and count($result) > 0) {
       if ($result and count($result) > 0) {
-        form_set_error('title', 'Cannot update the contact with this contact name. An contact with this name already exists.');
+        form_set_error('title', 'Cannot update the contact with this contact name. A contact with this name already exists.');
         return;
         return;
       }  
       }  
     }
     }
@@ -204,7 +204,7 @@ function chado_contact_validate($node, $form, &$form_state) {
     );
     );
     $contact = tripal_core_chado_select('contact', array('contact_id'), $values);
     $contact = tripal_core_chado_select('contact', array('contact_id'), $values);
     if ($contact and count($contact) > 0) {
     if ($contact and count($contact) > 0) {
-      form_set_error('title', 'Cannot add the contact with this name. An contact with these values already exists.');
+      form_set_error('title', 'Cannot add the contact with this name. A contact with these values already exists.');
       return;
       return;
     }
     }
   }
   }

+ 8 - 6
tripal_core/api/tripal_core_properties.api.inc

@@ -355,14 +355,14 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
  *   value should be that of the contact_id.  This is the record from which currently assigned
  *   value should be that of the contact_id.  This is the record from which currently assigned
  *   properties will be retrieved.
  *   properties will be retrieved.
  * @param $exclude
  * @param $exclude
- *   An array of cvterms to exclude when retreiving terms already saved in the database.
+ *   An optional array of cvterms to exclude when retreiving terms already saved in the database.
  *   Use this array when properties are present but should be handled elsewhere.
  *   Use this array when properties are present but should be handled elsewhere.
  *   For example, for contacts, the description field is stored as a property because 
  *   For example, for contacts, the description field is stored as a property because 
  *   the actual field is only 255 characters. The 'contact_description' therefore should
  *   the actual field is only 255 characters. The 'contact_description' therefore should
  *   not be shown in the list of properties, even if present, because it is handled by
  *   not be shown in the list of properties, even if present, because it is handled by
  *   a different form element.
  *   a different form element.
  * @param $include
  * @param $include
- *   An array of terms to pre-populate in the form.  This argument can be used to
+ *   An optional array of terms to pre-populate in the form.  This argument can be used to
  *   add a default set of pre-populated properties regardless if they exist in the database
  *   add a default set of pre-populated properties regardless if they exist in the database
  *   or not.  The array should be of the following form:
  *   or not.  The array should be of the following form:
  *     array(
  *     array(
@@ -372,12 +372,14 @@ function tripal_core_delete_property_by_id($basetable, $record_id) {
  *     );
  *     );
  *   The 'cvterm' key should have as a value an object with these properties: 'name', 'cvterm_id', 'definition'. 
  *   The 'cvterm' key should have as a value an object with these properties: 'name', 'cvterm_id', 'definition'. 
  * @param $instructions
  * @param $instructions
- *   An additional set of instructions for the form properties.
- *   
+ *   An optional additional set of instructions for the form properties.
+ * @param $fset_title
+ *   A title for the property field set.  The default is 'Additional Details'.
  * @ingroup tripal_properties_api
  * @ingroup tripal_properties_api
  */
  */
 function tripal_core_properties_form(&$form, &$form_state, $prop_table, $id_field, $cv_name,
 function tripal_core_properties_form(&$form, &$form_state, $prop_table, $id_field, $cv_name,
-    $available_props, $id = NULL, $exclude = array(), $include = array(), $instructions = '') {
+    $available_props, $id = NULL, $exclude = array(), $include = array(), $instructions = '', 
+    $fset_title = 'Additional Details') {
   
   
   $d_removed      = array(); // lists removed properties
   $d_removed      = array(); // lists removed properties
   $num_new        = 0;  // the number of new rows
   $num_new        = 0;  // the number of new rows
@@ -397,7 +399,7 @@ function tripal_core_properties_form(&$form, &$form_state, $prop_table, $id_fiel
   
   
   $form['properties'] = array(
   $form['properties'] = array(
     '#type' => 'fieldset',
     '#type' => 'fieldset',
-    '#title' => t('Additional Details'),
+    '#title' => t($fset_title),
     '#description' => t('You may add additional properties by
     '#description' => t('You may add additional properties by
       selecting a property type from the dropdown and adding text.  You may add
       selecting a property type from the dropdown and adding text.  You may add
       as many properties as desired by clicking the add button on the right.  To
       as many properties as desired by clicking the add button on the right.  To

+ 2 - 2
tripal_pub/includes/pub_form.inc

@@ -213,10 +213,10 @@ function chado_pub_form($node, $form_state) {
   // add in the properties fields. The 'Citation' term is special because it serves
   // add in the properties fields. The 'Citation' term is special because it serves
   // both as a property and as the uniquename for the publiation table so we exclude it
   // both as a property and as the uniquename for the publiation table so we exclude it
   // as it shouldn't be selected as a property
   // as it shouldn't be selected as a property
-  $exclude = array("Citation");
+  $exclude = array("Citation"); 
   $instructions = '';
   $instructions = '';
   tripal_core_properties_form($form, $form_state, 'pubprop', 'pub_id', 'tripal_pub',
   tripal_core_properties_form($form, $form_state, 'pubprop', 'pub_id', 'tripal_pub',
-    $properties, $pub_id, $exclude, $more_props, $instructions);
+    $properties, $pub_id, $exclude, $more_props, $instructions, 'Properties');
 
 
   return $form;
   return $form;