? misc/formcheck.js
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.476
diff -u -r1.476 common.inc
--- includes/common.inc	31 Aug 2005 18:37:30 -0000	1.476
+++ includes/common.inc	13 Sep 2005 17:22:08 -0000
@@ -1030,13 +1030,34 @@
  *   The URL to send the form contents to, if not the current page.
  * @param $attributes
  *   An associative array of attributes to add to the form tag.
+ * @param $formcheck
+ *   Whether or not to prompt a user if they leave a page with changed form data
  * @result
  *   An HTML string with the contents of $form wrapped in a form tag.
  */
-function form($form, $method = 'post', $action = NULL, $attributes = NULL) {
+function form($form, $method = 'post', $action = NULL, $attributes = NULL, $formcheck = FALSE) {
   if (!$action) {
     $action = request_uri();
   }
+  
+  if ($formcheck) {
+    drupal_add_js('misc/formcheck.js');
+ 
+    if (!isset($attributes['onsubmit'])) {
+      $attributes['onsubmit'] = 'isSubmit=true;';
+    }
+    else {
+      $attributes['onsubmit'] = 'isSubmit=true;' . $attributes['onsubmit'];
+    }
+
+    if (!isset($attributes['formcheck'])) {
+      $attributes['class'] = 'formcheck';
+    }
+    else {
+      $attributes['class'] .= ' formcheck';
+    }
+  }
+  
   // Anonymous div to satisfy XHTML compliancy.
   return '<form action="'. check_url($action) .'" method="'. $method .'"'. drupal_attributes($attributes) .">\n<div>". $form ."\n</div></form>\n";
 }
Index: modules/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node.module,v
retrieving revision 1.527
diff -u -r1.527 node.module
--- modules/node.module	2 Sep 2005 02:11:41 -0000	1.527
+++ modules/node.module	13 Sep 2005 17:14:10 -0000
@@ -1409,7 +1409,7 @@
   if (is_array($param['options'])) {
     $attributes = array_merge($param['options'], $attributes);
   }
-  return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes);
+  return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes, TRUE);
 }
 
 /**