From 5fea19e8b6bed9277686f70d97656adea90887b5 Mon Sep 17 00:00:00 2001
From: Neil Drumm <drumm@3064.no-reply.drupal.org>
Date: Sun, 30 Apr 2006 00:43:53 +0000
Subject: [PATCH] Forward port from 4.7 #59935, It's impossible to preserve
 stuff by calling form_set_value from hook_validate to submit, patch by
 tenrapid

---
 modules/node.module      | 7 +++++--
 modules/node/node.module | 7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/node.module b/modules/node.module
index 3a57c1c873d6..ab6ae83e1920 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1659,12 +1659,15 @@ function node_form_array($node) {
   return $form;
 }
 
-function node_form_add_preview($form, $edit) {
+function node_form_add_preview($form) {
+  global $form_values;
+  
   $op = isset($_POST['op']) ? $_POST['op'] : '';
   if ($op == t('Preview')) {
     drupal_validate_form($form['form_id']['#value'], $form);
     if (!form_get_errors()) {
-      $form['node_preview'] = array('#value' => node_preview((object)$edit), '#weight' => -100);
+      // We pass the global $form_values here to preserve changes made during form validation
+      $form['node_preview'] = array('#value' => node_preview((object)$form_values), '#weight' => -100);
     }
   }
   if (variable_get('node_preview', 0) && (form_get_errors() || $op != t('Preview'))) {
diff --git a/modules/node/node.module b/modules/node/node.module
index 3a57c1c873d6..ab6ae83e1920 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1659,12 +1659,15 @@ function node_form_array($node) {
   return $form;
 }
 
-function node_form_add_preview($form, $edit) {
+function node_form_add_preview($form) {
+  global $form_values;
+  
   $op = isset($_POST['op']) ? $_POST['op'] : '';
   if ($op == t('Preview')) {
     drupal_validate_form($form['form_id']['#value'], $form);
     if (!form_get_errors()) {
-      $form['node_preview'] = array('#value' => node_preview((object)$edit), '#weight' => -100);
+      // We pass the global $form_values here to preserve changes made during form validation
+      $form['node_preview'] = array('#value' => node_preview((object)$form_values), '#weight' => -100);
     }
   }
   if (variable_get('node_preview', 0) && (form_get_errors() || $op != t('Preview'))) {
-- 
GitLab