Tripal
Functions
tripal_core.chado_nodes.dbxrefs.api.inc File Reference

Functions

 chado_add_node_form_dbxrefs (&$form, &$form_state, $details)
 
 chado_add_node_form_dbxrefs_add_button_validate ($form, &$form_state)
 
 chado_add_node_form_dbxrefs_add_button_submit ($form, &$form_state)
 
 chado_add_node_form_dbxrefs_remove_button_validate ($form, $form_state)
 
 chado_add_node_form_dbxrefs_remove_button_submit (&$form, &$form_state)
 
 chado_add_node_form_dbxrefs_create_dbxref_formstate_array ($form, &$form_state)
 
 theme_chado_add_node_form_dbxrefs_table ($variables)
 
 chado_retrieve_node_form_dbxrefs ($node)
 
 chado_update_node_form_dbxrefs ($node, $details, $retrieved_dbxrefs=FALSE)
 

Detailed Description

API to manage the Chado dbxref table for various Tripal Node Types

How To Use:

function chado_example_form($form, &$form_state) {
// Default values for form elements can come in the following ways:
//
// 1) as elements of the $node object. This occurs when editing an existing
node
// 2) in the $form_state['values'] array which occurs on a failed validation
or
// ajax callbacks when the ajax call originates from non-submit fields
other
// than button
// 3) in the $form_state['input'] array which occurs on ajax callbacks from
submit
// form elements (e.g. buttons) and the form is being rebuilt but has not
yet
// been validated
//
// The reference elements added by this function do use AJAX calls from
buttons,
// therefore, it is important to check for form values in the
$form_state['values']
// for case #2 above, and in the $form_state['input'] for case #3.
// See the chado analysis node form for an example.
// Next, add in all the form array definition particular to your node type
// To add in the additional database reference form elements, you first need
to prepare the arguments
// for the function call.
$details = array(
'linking_table' => 'example_dbxref', // the name of the table
linking additional dbxrefs to this node
'base_foreign_key' => 'example_id', // key to link to the chado
content created by this node
'base_key_value' => $example_id, // the value of the above key
'fieldset_title' => 'Additional References', // the non-translated title for
this fieldset
'additional_instructions' => '' // a non-stranslated string
providing additional instructions
);
// Finally, and add the additional form elements to the form
chado_add_node_form_dbxrefs($form, $form_state, $details);
return $form;
}
function chado_example_insert($node) {
// if there is an example_id in the $node object then this must be a sync so
// we can skip adding the chado_example as it is already there, although
// we do need to proceed with the rest of the insert
if (!property_exists($node, 'example_id')) {
// Add record to chado example table
// Add to any other tables needed
// Add all additional database references
// This function will create new database references as needed and select
existing ones.
// Existing _dbxref links will be cleared and then re-added
chado_update_node_form_dbxrefs(
$node, // the node object passed in via hook_insert()
'example_dbxref', // the name of the _dbxref linking table
'example_id', // key to link to the chado content created by this node
$node->example_id // value of the above key
);
}
// Add record to chado_example linking example_id to new node
}
function chado_example_update($node) {
// Update record in chado example table
// Update any other tables needed
// Update all additional database references
// This function will create new database references as needed and select
existing ones.
// Existing _dbxref links will be cleared and then re-added
chado_update_node_form_dbxrefs(
$node, // the node object passed in via hook_insert()
'example_dbxref', // the name of the _dbxref linking table
'example_id', // key to link to the chado content created by this node
$node->example_id // value of the above key
);
// Don't need to update chado_example linking table since niether example_id
or nid can be changed in update
}
chado_add_node_form_dbxrefs(&$form, &$form_state, $details)
Definition: tripal_core.chado_nodes.dbxrefs.api.inc:142

Function Documentation

◆ chado_add_node_form_dbxrefs_add_button_submit()

chado_add_node_form_dbxrefs_add_button_submit (   $form,
$form_state 
)

Called by the add button in chado_add_node_form_dbxrefs

Create an array of additional dbxrefs in the form state. This array will then be used to rebuild the form in subsequent builds

◆ chado_add_node_form_dbxrefs_add_button_validate()

chado_add_node_form_dbxrefs_add_button_validate (   $form,
$form_state 
)

Validate the user input for creating a new dbxref Called by the add button in chado_add_node_form_dbxrefs

◆ chado_add_node_form_dbxrefs_create_dbxref_formstate_array()

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], ), );

◆ chado_add_node_form_dbxrefs_remove_button_submit()

chado_add_node_form_dbxrefs_remove_button_submit ( $form,
$form_state 
)

Remove the correct dbxref from the form Called by the many remove buttons in chado_add_node_form_dbxrefs

◆ chado_add_node_form_dbxrefs_remove_button_validate()

chado_add_node_form_dbxrefs_remove_button_validate (   $form,
  $form_state 
)

Called by the many remove buttons in chado_add_node_form_dbxrefs

◆ theme_chado_add_node_form_dbxrefs_table()

theme_chado_add_node_form_dbxrefs_table (   $variables)

Function to theme the add/remove dbxrefs form into a table