1 ajax_example_advanced.inc ajax_example_advanced_commands_changed_callback($form, $form_state)

Callback for 'changed'.

See also

ajax_command_changed()

File

modules/examples/ajax_example/ajax_example_advanced.inc, line 287
AJAX Commands examples.

Code

function ajax_example_advanced_commands_changed_callback($form, $form_state) {
  $checkbox_value = $form_state['values']['changed_command_example'];
  $checkbox_value_string = $checkbox_value ? "TRUE" : "FALSE";
  $commands = array();
  if ($checkbox_value) {
    $commands[] = ajax_command_changed('#changed_div', '#changed_div_mark_this');
  }
  else {
    $commands[] = ajax_command_replace('#changed_div', "<div id='changed_div'> <div id='changed_div_mark_this'>This div can be marked as changed or not.</div></div>");
  }
  $commands[] = ajax_command_replace("#changed_status", "<div id='changed_status'>Updated changed_command_example to $checkbox_value_string: " . date('r') . "</div>");
  return array('#type' => 'ajax', '#commands' => $commands);
}