function chado_add_node_form_subtable_ajax_update

2.x tripal_core.chado_nodes.api.inc chado_add_node_form_subtable_ajax_update($form, &$form_state)

Ajax function which returns the section of the form to be re-rendered for either the properties, dbxref or relationship sub-sections.

Related topics

1 string reference to 'chado_add_node_form_subtable_ajax_update'
chado_add_node_form_relationships in tripal_core/api/tripal_core.chado_nodes.relationships.api.inc
Provides a form for adding to BASE_relationship and relationship tables

File

tripal_core/api/tripal_core.chado_nodes.api.inc, line 308
API to handle much of the common functionality implemented when creating a drupal node type.

Code

function chado_add_node_form_subtable_ajax_update($form, &$form_state) {

  // We need to validate the trigerring element since Drupal has known
  // issues determining this correctly when there are multiple buttons
  // with the same label.
  chado_validate_node_form_triggering_element($form, $form_state);

  // Based on triggering element render the correct part of the form.
  // ASUMPTION: each of the buttons must have property, dbxref or relationship
  // as the first part of the #name to uniquely identify the subsection.
  if (preg_match('/^([a-z]+).*/', $form_state['triggering_element']['#name'], $matches)) {
    $subsection = $matches[1];

    switch ($subsection) {
      case 'properties':
        return $form['properties']['property_table'];
        break;
      case 'dbxrefs':
        return $form['addtl_dbxrefs']['dbxref_table'];
        break;
      case 'relationships':
        return $form['relationships']['relationship_table'];
        break;
    }
  }
}