diff --git a/cck_private_fields.module b/cck_private_fields.module
index 2da0978..7aac9e5 100644
--- a/cck_private_fields.module
+++ b/cck_private_fields.module
@@ -296,3 +296,24 @@ function theme_cck_private_fields_privacy_icon($classname, $readable) {
   );
   return '<div' . drupal_attributes($attributes) . '><span>' . $readable. '</span></div>';
 }
+
+/**
+ * Adds the JS and CSS files that cck private fields needs.
+ *
+ * @see _cck_private_fields_node_form_alter.
+ */
+function _cck_private_fields_add_files($form) {
+  static $js_settings_processed;
+  // Make sure Drupal settings and files are not sent more than once per page.
+  if (!isset($js_settings_processed) && !isset($form['#_cck_private_fields_add_files'])) {
+    $form['#_cck_private_fields_add_files'] = TRUE;
+    // Send our javascript and stylesheets to the page.
+    $module_path = drupal_get_path('module', 'cck_private_fields');
+    drupal_add_css($module_path .'/css/privacy_status_dialog.css');
+    drupal_add_js($module_path .'/js/privacy_status_dialog.js');
+    jquery_ui_add(array('ui.dialog', 'ui.draggable'));
+    drupal_add_js(array('CCKPrivateFields' => $form['#cck_private_fields_js']), 'setting');
+    $js_settings_processed = TRUE;
+  }
+  return $form;
+}
\ No newline at end of file
diff --git a/includes/node_form.inc b/includes/node_form.inc
index b9a4bbf..67467ad 100644
--- a/includes/node_form.inc
+++ b/includes/node_form.inc
@@ -20,8 +20,6 @@
  * @see cck_private_fields_form_alter()
  */
 function _cck_private_fields_node_form_alter(&$form, &$form_state, $private_fields) {
-  static $js_settings_processed;
-
   // Configure privacy options for fields in this node form.
   $privacy_status_options = array(
     CCK_FIELDS_PRIVACY_STATUS_PUBLIC => array(
@@ -108,25 +106,15 @@ function _cck_private_fields_node_form_alter(&$form, &$form_state, $private_fiel
 
   // Prepare the form for private fields handling.
   $form['#cck_private_fields'] = $private_fields;
+  $form['#cck_private_fields_js'] = $js_settings;
   $form['cck_private_fields'] = array(
     '#tree' => TRUE,
     '#weight' => 100,
   );
 
+  $form['#pre_render'][] = '_cck_private_fields_add_files';
   // Scan the form recursively to find fields with privacy options enabled.
   _cck_private_fields_node_form_recursive($form, $form, $form_state);
-
-  // Send our javascript and stylesheets to the page.
-  $module_path = drupal_get_path('module', 'cck_private_fields');
-  drupal_add_css($module_path .'/css/privacy_status_dialog.css');
-  drupal_add_js($module_path .'/js/privacy_status_dialog.js');
-  jquery_ui_add(array('ui.dialog', 'ui.draggable'));
-
-  // Make sure Drupal settings are not sent more than once per page.
-  if (!isset($js_settings_processed)) {
-    drupal_add_js(array('CCKPrivateFields' => $js_settings), 'setting');
-    $js_settings_processed = TRUE;
-  }
 }
 
 /**
