You are here

function oa_core_oa_section_ref_replace in Open Atrium Core 7.2

Ajax callback to return the section field.

1 string reference to 'oa_core_oa_section_ref_replace'
oa_core_oa_section_ref_process in includes/oa_core.fields.inc
Process function of the oa_section_ref field.

File

includes/oa_core.fields.inc, line 260
Code for custom Form API fields in Open Atrium

Code

function oa_core_oa_section_ref_replace($form, $form_state) {
  $field_name_triggering = implode('--', $form_state['triggering_element']['#parents']);
  $return = array(
    '#type' => 'ajax',
    '#commands' => array(),
  );
  $group_element =& _oa_core_oa_section_ref_process_find_element($form, $form_state['triggering_element']['#parents']);
  if ($messages = theme('status_messages')) {
    $selector = '#' . $group_element['messages']['#attributes']['id'];
    $html = '<div class="views-messages">' . $messages . '</div>';
    $return['#commands'][] = ajax_command_replace($selector, $html);
  }
  if (!isset($form_state['oa_section_ref_replace'][$field_name_triggering])) {
    return $return;
  }

  // Replace the section element.
  $section_element =& _oa_core_oa_section_ref_process_find_element($form, $form_state['oa_section_ref_replace'][$field_name_triggering]['parents']);
  $return['#commands'][] = ajax_command_replace('#' . $section_element['#ajax_id'] . '-replace', render($section_element));
  return $return;
}