function chado_add_node_form_relationships_create_relationship_formstate_array

2.x tripal_core.chado_nodes.relationships.api.inc chado_add_node_form_relationships_create_relationship_formstate_array($form, &$form_state)
3.x tripal_core.chado_nodes.relationships.api.inc chado_add_node_form_relationships_create_relationship_formstate_array($form, &$form_state)

Creates an array in form_state containing the existing relationships. This array is then modified by the add/remove buttons and used as a source for rebuilding the form.

$form_state['chado_relationships'] = array( '[type_id]-[rank]' => array( 'object_id' => [the _relationship.object_id value], 'object_name' => [the base_table.uniquename value linked on base_foreign_key=object_id], 'subject_id' => [the _relationship.subject_id value], 'subject_name' => [the base_table.uniquename value linked on base_foreign_key=subject_id], 'type_id' => [the _relationship.type_id value], 'type_name' => [the cvterm.name value linked on type_id], 'rank' => [the _relationship.rank value], ), );

Related topics

2 calls to chado_add_node_form_relationships_create_relationship_formstate_array()
chado_add_node_form_relationships_add_button_submit in tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Called by the add button in chado_add_node_form_relationships
chado_add_node_form_relationships_remove_button_submit in tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Remove the correct relationship from the form Called by the many remove buttons in chado_add_node_form_relationships

File

tripal_core/api/tripal_core.chado_nodes.relationships.api.inc, line 833
API to manage the chado _relationship table for various Tripal Node Types

Code

function chado_add_node_form_relationships_create_relationship_formstate_array($form, &$form_state) {

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

  foreach (element_children($form['relationships']['relationship_table']) as $type_id) {
    if ($type_id != 'new') {
      foreach (element_children($form['relationships']['relationship_table'][$type_id]) as $relationship_id) {
        $element = $form['relationships']['relationship_table'][$type_id][$relationship_id];
        $rel = array(
          'type_id' => $element['type_id']['#value'],
          'object_id' => $element['object_id']['#value'],
          'subject_id' => $element['subject_id']['#value'],
          'type_name' => $element['type_name']['#markup'],
          'object_name' => $element['object_name']['#markup'],
          'subject_name' => $element['subject_name']['#markup'],
          'rank' => $element['rank']['#markup'],
          'relationship_id' => $relationship_id,
        );
        $key = $rel['type_id'] . '-' . $rel['relationship_id'];
        $form_state['chado_relationships'][$key] = (object) $rel;
      }
    }
  }
}