Index: /CKEditor/trunk/_samples/replacebyclass.html
===================================================================
--- /CKEditor/trunk/_samples/replacebyclass.html	(revision 3004)
+++ /CKEditor/trunk/_samples/replacebyclass.html	(revision 3005)
@@ -11,5 +11,5 @@
 <body>
 	<div id="html">
-		<form action="">
+		<form action="sample_posteddata.php" method="post">
 			<p>
 				<label for="editor1">
Index: /CKEditor/trunk/_samples/replacebycode.html
===================================================================
--- /CKEditor/trunk/_samples/replacebycode.html	(revision 3004)
+++ /CKEditor/trunk/_samples/replacebycode.html	(revision 3005)
@@ -11,5 +11,5 @@
 <body>
 	<div id="html">
-		<form action="">
+		<form action="sample_posteddata.php" method="post">
 			<p>
 				<label for="editor1">
Index: /CKEditor/trunk/_samples/sample.css
===================================================================
--- /CKEditor/trunk/_samples/sample.css	(revision 3004)
+++ /CKEditor/trunk/_samples/sample.css	(revision 3005)
@@ -48,2 +48,34 @@
 	float: right;
 }
+
+#outputSample
+{
+	width: 100%;
+	table-layout: fixed;
+}
+
+#outputSample thead th
+{
+	color: #dddddd;
+	background-color: #999999;
+	padding: 4px;
+	white-space: nowrap;
+}
+
+#outputSample tbody th
+{
+	vertical-align: top;
+	text-align: left;
+}
+
+#outputSample pre
+{
+	margin: 0;
+	padding: 0;
+	white-space: pre; /* CSS2 */
+	white-space: -moz-pre-wrap; /* Mozilla*/
+	white-space: -o-pre-wrap; /* Opera 7 */
+	white-space: pre-wrap; /* CSS 2.1 */
+	white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
+	word-wrap: break-word; /* IE */
+}
Index: /CKEditor/trunk/_samples/sample_posteddata.php
===================================================================
--- /CKEditor/trunk/_samples/sample_posteddata.php	(revision 3005)
+++ /CKEditor/trunk/_samples/sample_posteddata.php	(revision 3005)
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?php
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+	<title>Sample - CKEditor</title>
+	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+	<link type="text/css" rel="stylesheet" href="sample.css" />
+</head>
+<body>
+	<h1>
+		CKEditor - Posted Data
+	</h1>
+	<table border="1" cellspacing="0" id="outputSample">
+		<colgroup><col width="100" /></colgroup>
+		<thead>
+			<tr>
+				<th>Field&nbsp;Name</th>
+				<th>Value</th>
+			</tr>
+		</thead>
+<?php
+
+if ( isset( $_POST ) )
+	$postArray = &$_POST ;			// 4.1.0 or later, use $_POST
+else
+	$postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS
+
+foreach ( $postArray as $sForm => $value )
+{
+	if ( get_magic_quotes_gpc() )
+		$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
+	else
+		$postedValue = htmlspecialchars( $value ) ;
+
+?>
+		<tr>
+			<th style="vertical-align: top"><?php echo $sForm?></th>
+			<td><pre><?php echo $postedValue?></pre></td>
+		</tr>
+	<?php
+}
+?>
+	</table>
+	<div id="footer">
+		<hr />
+		<p>
+			CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>
+		</p>
+		<p id="copy">
+			Copyright &copy; 2003-2009, <a href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved.
+		</p>
+	</div>
+</body>
+</html>
Index: /CKEditor/trunk/_source/core/config.js
===================================================================
--- /CKEditor/trunk/_source/core/config.js	(revision 3004)
+++ /CKEditor/trunk/_source/core/config.js	(revision 3005)
@@ -38,4 +38,6 @@
 	 */
 	customConfig : CKEDITOR.getUrl( 'config.js' ),
+
+	autoUpdateElement : true,
 
 	/**
Index: /CKEditor/trunk/_source/core/editor.js
===================================================================
--- /CKEditor/trunk/_source/core/editor.js	(revision 3004)
+++ /CKEditor/trunk/_source/core/editor.js	(revision 3005)
@@ -213,5 +213,39 @@
 				editorTheme.path = CKEDITOR.themes.getPath( theme );
 				editorTheme.build( editor );
+
+				if ( editor.config.autoUpdateElement )
+					attachToForm( editor );
 			});
+	};
+
+	var attachToForm = function( editor )
+	{
+		var element = editor.element;
+
+		// If are replacing a textarea, we must
+		if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.is( 'textarea' ) )
+		{
+			var form = new CKEDITOR.dom.element( element.$.form );
+			if ( form )
+			{
+				form.on( 'submit', function()
+					{
+						editor.updateElement()
+					});
+
+				// If we have a submit function, override it also, because it doesn't fire the "submit" event.
+				if ( form.submit && form.submit.call )
+				{
+					CKEDITOR.tools.override( form.submit, function( originalSubmit )
+						{
+							return function()
+								{
+									editor.updateElement();
+									originalSubmit.apply( this, arguments );
+								};
+						});
+				}
+			}
+		}
 	};
 
@@ -241,5 +275,5 @@
 			 * alert( <b>editor.element</b>.getName() );  "textarea"
 			 */
-			this.element = element && element;
+			this.element = element;
 
 			/**
