1 ajax_example_node_form_alter.inc ajax_example_node_update($node)

Implements hook_node_update().

See also

ajax_example_form_node_form_alter()

File

modules/examples/ajax_example/ajax_example_node_form_alter.inc, line 125
This example shows how to use AJAX when altering a node form.

Code

function ajax_example_node_update($node) {
  if (db_select('ajax_example_node_form_alter', 'a')->fields('a')->condition('nid', $node->nid, '=')->execute()->fetchAssoc()) {
    db_update('ajax_example_node_form_alter')
      ->fields(array(
        'example_1' => $node->ajax_example['example_1'],
        'example_2' => $node->ajax_example['example_2'],
      ))
      ->condition('nid', $node->nid)
      ->execute();
  }
  else {
    // Cleaner than doing it again.
    ajax_example_node_insert($node);
  }
}