? files ? generate-content.php ? 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 15:03:08 -0000 @@ -1030,13 +1030,27 @@ * 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']; + } + } + // Anonymous div to satisfy XHTML compliancy. return '
\n
". $form ."\n
\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 12 Sep 2005 21:53:56 -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); } /**