function chado_add_node_form_dbxrefs_create_dbxref_formstate_array

2.x tripal_core.chado_nodes.dbxrefs.api.inc chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form_state)
3.x tripal_core.chado_nodes.dbxrefs.api.inc chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form_state)

Creates an array in form_state containing the existing addtl_dbxrefs. This array is then modified by the add/remove buttons and used as a source for rebuilding the form. This function get's called at each button (add and remove) button submits the first time one of the button's is clicked to instantiates the $form_state['chado_additional_dbxrefs'] array

$form_state['chado_additional_dbxrefs'] = array( '[db_id]-[version]' => array( 'db_id' => [the db.db_id value] 'db_name' => [the db.name value] 'dbxref_id' => [the dbxref.dbxref_id value, or temporary value if it doesn't yet exists], 'version' => [the dbxref.version value], 'accession' => [the dbxref.accession value], ), );

Related topics

2 calls to chado_add_node_form_dbxrefs_create_dbxref_formstate_array()
chado_add_node_form_dbxrefs_add_button_submit in tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
Called by the add button in chado_add_node_form_dbxrefs
chado_add_node_form_dbxrefs_remove_button_submit in tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc
Remove the correct dbxref from the form Called by the many remove buttons in chado_add_node_form_dbxrefs

File

tripal_core/api/tripal_core.chado_nodes.dbxrefs.api.inc, line 550
API to manage the chado _dbxref table for various Tripal Node Types

Code

function chado_add_node_form_dbxrefs_create_dbxref_formstate_array($form, &$form_state) {

  $form_state['chado_additional_dbxrefs'] = array();

  foreach (element_children($form['addtl_dbxrefs']['dbxref_table']) as $db_id) {
    if ($db_id != 'new') {
      foreach (element_children($form['addtl_dbxrefs']['dbxref_table'][$db_id]) as $version) {
        $element = $form['addtl_dbxrefs']['dbxref_table'][$db_id][$version];
        $dbxref = array(
          'db_id' => $element['db_id']['#value'],
          'db_name' => $element['db']['#markup'],
          'dbxref_id' => $element['dbxref_id']['#value'],
          'version' => $element['dbxref_version']['#markup'],
          'accession' => $element['dbxref_accession']['#markup'],
        );
        $key = $dbxref['db_id'] . '-' . $dbxref['dbxref_id'];
        $form_state['chado_additional_dbxrefs'][$key] = (object) $dbxref;
      }
    }
  }
}