ソースを参照

Issue 1764346 #1: Added an is_unique check to the edit record to ensure that the record name remains unique

Lacey Sanderson 12 年 前
コミット
efc0acb2b2
1 ファイル変更16 行追加2 行削除
  1. 16 2
      tripal_bulk_loader/tripal_bulk_loader.admin.templates.inc

+ 16 - 2
tripal_bulk_loader/tripal_bulk_loader.admin.templates.inc

@@ -872,6 +872,21 @@ function tripal_bulk_loader_edit_template_record_form(&$form_state = NULL) {
   return $form;
 }
 
+function tripal_bulk_loader_edit_template_record_form_validate($form, $form_state) {
+
+  // Don't worry about validation when Cancel button is clicked
+  if ($form_state['clicked_button']['#value'] == 'Edit Record') {
+    $is_unique = tripal_bulk_loader_is_record_name_unique(
+      $form_state['values']['record_name'],
+      $form_state['values']['template_id'],
+      $form_state['storage']['template_array']
+    );
+    if (!$is_unique) {
+      form_set_error('record_name', "New Record Name must be unique. '" . $form_state['values']['record_name'] . "' is not unique.");
+    }
+  }
+
+}
 
 /**
  * Edit Record Form Submit
@@ -2277,8 +2292,7 @@ function tripal_bulk_loader_edit_template_field_form_validate($form, $form_state
       $form_state['values']['template_id'],
       $form_state['storage']['template_array']
     );
-    $new_record = ($form_state['values']['field_group'] == 'NEW') ? TRUE : FALSE;
-    if ((!$is_unique) AND $new_record) {
+    if (!$is_unique) {
       form_set_error('record_name', "New Record Name must be unique. '" . $form_state['values']['record_name'] . "' is not unique.");
     }
   }