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

Functions

 chado_add_node_form_properties (&$form, &$form_state, $details)
 
 chado_add_node_form_properties_add_button_validate ($form, &$form_state)
 
 chado_add_node_form_properties_add_button_submit ($form, &$form_state)
 
 chado_add_node_form_properties_remove_button_validate ($form, &$form_state)
 
 chado_add_node_form_properties_remove_button_submit (&$form, &$form_state)
 
 chado_add_node_form_properties_ajax_desc ($form, $form_state)
 
 chado_add_node_form_properties_create_property_formstate_array ($form, &$form_state)
 
 theme_chado_add_node_form_properties ($variables)
 
 chado_retrieve_node_form_properties ($node)
 
 chado_update_node_form_properties ($node, $details, $retrieved_properties=FALSE)
 

Detailed Description

API to manage the chado prop 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 chado properties form elements, you first need to prepare
the arguments
// for the function call.
$details = array(
'property_table' => 'example_property', // the name of the table
linking additional properties to this node
'chado_id_field' => 'example_id', // key to link to the chado
content created by this node
'chado_id' => $example_id, // the value of the above key
'cv_name' => 'example_prop_cv', // the name of the cv governing
the _prop.type_id
'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_properties($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 properties
// Existing _property links will be cleared and then re-added
tripal_api_chado_node_properties_form_update_properties(
$node, // the node object passed in via hook_insert()
'example_property', // the name of the _property linking table
'example', // the name of the base chado table for the node
'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 properties
// Existing _property links will be cleared and then re-added
tripal_api_chado_node_properties_form_update_properties(
$node, // the node object passed in via hook_insert()
'example_property', // the name of the _property linking table
'example', // the name of the base chado table for the node
'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_properties(&$form, &$form_state, $details)
Definition: tripal_core.chado_nodes.properties.api.inc:158

Function Documentation

◆ chado_add_node_form_properties_add_button_submit()

chado_add_node_form_properties_add_button_submit (   $form,
$form_state 
)

Called by the add button in chado_add_node_form_properties

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

◆ chado_add_node_form_properties_add_button_validate()

chado_add_node_form_properties_add_button_validate (   $form,
$form_state 
)

Validate the user input for creating a new property Called by the add button in chado_add_node_form_properties

◆ chado_add_node_form_properties_ajax_desc()

chado_add_node_form_properties_ajax_desc (   $form,
  $form_state 
)
Parameters
unknown$form
unknown$form_state
Returns
unknown

◆ chado_add_node_form_properties_create_property_formstate_array()

chado_add_node_form_properties_create_property_formstate_array (   $form,
$form_state 
)

Creates an array in form_state containing the existing properties. 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_properties'] array

$form_state['chado_properties'] = array( '[type_id]-[rank]' => array( 'type_id' => [the cvterm.cvterm_id value] 'type_name' => [the cvterm.name value] 'property_id' => [the property.property_id value, or NULL if it doesn't yet exist], 'value' => [the BASEprop.value value], 'rank' => [the BASEprop.rank value], ), );

◆ chado_add_node_form_properties_remove_button_submit()

chado_add_node_form_properties_remove_button_submit ( $form,
$form_state 
)

Remove the correct property from the form Called by the many remove buttons in chado_add_node_form_properties

◆ chado_add_node_form_properties_remove_button_validate()

chado_add_node_form_properties_remove_button_validate (   $form,
$form_state 
)

Called by the many remove buttons in chado_add_node_form_properties

◆ theme_chado_add_node_form_properties()

theme_chado_add_node_form_properties (   $variables)

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