summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-12-23 17:49:47 +0000
committerDries Buytaert <dries@buytaert.net>2006-12-23 17:49:47 +0000
commit2076e518a9f903491f8e1d3b269fe7df85cc4984 (patch)
treed0c90d8bafe0e248e98ebb49acc5b8d2269f2b4b /modules/node/node.module
parent96c913dca9e3299982069e20f9c45de917bc95ff (diff)
downloadbrdo-2076e518a9f903491f8e1d3b269fe7df85cc4984.tar.gz
brdo-2076e518a9f903491f8e1d3b269fe7df85cc4984.tar.bz2
- Patch #104729 by dww et al: node_form_add_preview() destroys existing prefix values
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module13
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 81f311db8..f301e635a 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -2046,8 +2046,17 @@ function node_form_add_preview($form) {
if ($op == t('Preview')) {
drupal_validate_form($form['form_id']['#value'], $form);
if (!form_get_errors()) {
- // We pass the global $form_values here to preserve changes made during form validation
- $form['#prefix'] = node_preview((object)$form_values);
+ // Because the node preview may display a form, we must render it
+ // outside the node submission form tags using the #prefix property
+ // (i.e. to prevent illegally nested forms).
+ // If the node form already has a #prefix, we must preserve it.
+ // In this case, we put the preview before the #prefix so we keep
+ // the #prefix as "close" to the rest of the form as possible,
+ // for example, to keep a <div> only around the form, not the
+ // preview. We pass the global $form_values here to preserve
+ // changes made during form validation.
+ $preview = node_preview((object)$form_values);
+ $form['#prefix'] = isset($form['#prefix']) ? $preview . $form['#prefix'] : $preview;
}
}
if (variable_get('node_preview', 0) && (form_get_errors() || $op != t('Preview'))) {