public function data__accession_widget::submit

3.x data__accession_widget.inc public data__accession_widget::submit($form, &$form_state, $entity_type, $entity, $langcode, $delta)

Overrides TripalFieldWidget::submit

See also

TripalFieldWidget::submit()

File

tripal_chado/includes/TripalFields/data__accession/data__accession_widget.inc, line 120

Class

data__accession_widget

Code

public function submit($form, &$form_state, $entity_type, $entity, $langcode, $delta) {
  $field_name = $this->field['field_name'];
  $settings = $this->field['settings'];
  $field_name = $this->field['field_name'];
  $field_type = $this->field['type'];
  $field_table = $this->instance['settings']['chado_table'];
  $field_column = $this->instance['settings']['chado_column'];

  $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'];

  // If the accession doesn't exist then add it.
  if ($db_id and $accession) {
    $dbxref = chado_generate_var('dbxref', array('db_id' => $db_id, 'accession' => $accession));
    if (!$dbxref) {
      $values = array(
        'db_id' => $db_id,
        'accession' => $accession,
      );
      $dbxref = chado_insert_dbxref($values);
      $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;
    }
  }
}