Last example in the 2nd code sample: http://drupal.org/node/322774