|
@@ -84,9 +84,8 @@ function tripal_chado_db_edit_form($form, &$form_state) {
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
- // if
|
|
|
|
- we don't have a db_id then we can return the form, otherwise
|
|
|
|
- // add in the other fields
|
|
|
|
|
|
+ // If we don't have a db_id then we can return the form, otherwise
|
|
|
|
+ // add in the other fields.
|
|
if ($dbid) {
|
|
if ($dbid) {
|
|
tripal_chado_add_db_form_fields($form, $form_state, $dbid);
|
|
tripal_chado_add_db_form_fields($form, $form_state, $dbid);
|
|
|
|
|
|
@@ -94,19 +93,19 @@ function tripal_chado_db_edit_form($form, &$form_state) {
|
|
'#type' => 'submit',
|
|
'#type' => 'submit',
|
|
'#value' => t('Update'),
|
|
'#value' => t('Update'),
|
|
];
|
|
];
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
// Assert we have some configuration in our database.
|
|
// Assert we have some configuration in our database.
|
|
- $dbxref_count = chado_query('select count(dbxref_id) from {dbxref_id} WHERE db_id = :db_id', [':db_id'] => $dbid);
|
|
|
|
-
|
|
|
|
|
|
+ $dbxref_count = chado_query('select count(dbxref_id) from {dbxref} WHERE db_id = :db_id', [':db_id' => $dbid])->fetchField();
|
|
|
|
+
|
|
if ($dbxref_count == 0) {
|
|
if ($dbxref_count == 0) {
|
|
$form['delete'] = [
|
|
$form['delete'] = [
|
|
'#type' => 'submit',
|
|
'#type' => 'submit',
|
|
'#value' => t('Delete'),
|
|
'#value' => t('Delete'),
|
|
'#attributes' => ['onclick' => 'if(!confirm("Really Delete?")){return false;}'],
|
|
'#attributes' => ['onclick' => 'if(!confirm("Really Delete?")){return false;}'],
|
|
];
|
|
];
|
|
- } else {
|
|
|
|
- tripal_set_message('You cannot delete this db without first deleting the ${dbxref_count} dbxrefs associated with it.', TRIPAL_NOTICE);
|
|
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ tripal_set_message("You cannot delete this db without first deleting the ${dbxref_count} dbxrefs associated with it.", TRIPAL_NOTICE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|