|
@@ -99,7 +99,7 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
|
|
'#disabled' => $db_id ? FALSE : TRUE,
|
|
'#disabled' => $db_id ? FALSE : TRUE,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @see TripalFieldWidget::validate()
|
|
* @see TripalFieldWidget::validate()
|
|
*/
|
|
*/
|
|
@@ -111,7 +111,7 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
|
|
$field_table = $this->instance['settings']['chado_table'];
|
|
$field_table = $this->instance['settings']['chado_table'];
|
|
$field_column = $this->instance['settings']['chado_column'];
|
|
$field_column = $this->instance['settings']['chado_column'];
|
|
$base_table = $this->instance['settings']['base_table'];
|
|
$base_table = $this->instance['settings']['base_table'];
|
|
-
|
|
|
|
|
|
+
|
|
$schema = chado_get_schema($table_name);
|
|
$schema = chado_get_schema($table_name);
|
|
$pkey = $schema['primary key'][0];
|
|
$pkey = $schema['primary key'][0];
|
|
$fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
|
|
$fkeys = array_values($schema['foreign keys'][$base_table]['columns']);
|
|
@@ -122,6 +122,8 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
|
|
$db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
|
|
$db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
|
|
$accession = $form_state['values'][$field_name]['und'][$delta]['accession'];
|
|
$accession = $form_state['values'][$field_name]['und'][$delta]['accession'];
|
|
|
|
|
|
|
|
+ dpm('HERE: '.$db_id);
|
|
|
|
+
|
|
// If user did not select a database, we want to remove the dbxref record.
|
|
// If user did not select a database, we want to remove the dbxref record.
|
|
// We do this by setting all values to empty except the value and the
|
|
// We do this by setting all values to empty except the value and the
|
|
// primary key.
|
|
// primary key.
|
|
@@ -142,6 +144,26 @@ class sbo__database_cross_reference_widget extends ChadoFieldWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function submit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
|
|
|
|
+ $field_name = $this->field['field_name'];
|
|
|
|
+ $field_table = $this->instance['settings']['chado_table'];
|
|
|
|
+
|
|
|
|
+ $dbxref_id = $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__dbxref_id'];
|
|
|
|
+ $db_id = $form_state['values'][$field_name]['und'][$delta]['db_id'];
|
|
|
|
+ $accession = $form_state['values'][$field_name]['und'][$delta]['accession'];
|
|
|
|
+
|
|
|
|
+ dpm($db_id);
|
|
|
|
+
|
|
|
|
+ if($db_id and !$dbxref_id) {
|
|
|
|
+ $dbxref = chado_insert_dbxref([
|
|
|
|
+ 'db_id' => $db_id,
|
|
|
|
+ 'accession' => $accession
|
|
|
|
+ ]);
|
|
|
|
+ $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__dbxref_id'] = $dbxref->dbxref_id;
|
|
|
|
+ $form_state['values'][$field_name]['und'][$delta]['value'] = $dbxref->dbxref_id;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @see TripalFieldWidget::theme()
|
|
* @see TripalFieldWidget::theme()
|
|
*/
|
|
*/
|