Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.768
diff -u -p -u -r1.768 common.inc
--- includes/common.inc	16 May 2008 01:23:31 -0000	1.768
+++ includes/common.inc	20 May 2008 12:51:54 -0000
@@ -3014,6 +3014,9 @@ function drupal_common_theme() {
     'form_element' => array(
       'arguments' => array('element' => NULL, 'value' => NULL),
     ),
+    'children_only' => array(
+      'arguments' => array('element' => NULL),
+    ),
   );
 }
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.272
diff -u -p -u -r1.272 form.inc
--- includes/form.inc	6 May 2008 12:18:45 -0000	1.272
+++ includes/form.inc	20 May 2008 12:51:57 -0000
@@ -937,12 +937,7 @@ function form_builder($form_id, $form, &
   return $form;
 }
 
-/**
- * Populate the #value and #name properties of input elements so they
- * can be processed and rendered. Also, execute any #process handlers
- * attached to a specific element.
- */
-function _form_builder_handle_input_element($form_id, &$form, &$form_state, $complete_form) {
+function _form_generate_name_id(&$form) {
   if (!isset($form['#name'])) {
     $name = array_shift($form['#parents']);
     $form['#name'] = $name;
@@ -960,6 +955,15 @@ function _form_builder_handle_input_elem
   if (!isset($form['#id'])) {
     $form['#id'] = form_clean_id('edit-' . implode('-', $form['#parents']));
   }
+}
+
+/**
+ * Populate the #value and #name properties of input elements so they
+ * can be processed and rendered. Also, execute any #process handlers
+ * attached to a specific element.
+ */
+function _form_builder_handle_input_element($form_id, &$form, &$form_state, $complete_form) {
+  _form_generate_name_id($form);
 
   unset($edit);
   if (!empty($form['#disabled'])) {
@@ -1824,6 +1828,48 @@ function form_expand_ahah($element) {
 }
 
 /**
+ * Expand input format support. Add format selector.
+ */
+function form_expand_format($element) {
+  if (isset($element['#input_format'])) {
+    $filter_form = filter_form($element['#input_format'], 10, $element['#parents']);
+    unset($element['#input_format']);
+    $element = array(
+      'input' => $element,
+      'format' => $filter_form,
+      '#type' => 'children_only',
+      '#parents' => $element['#parents'],
+      '#post' => $element['#post'],
+      '#programmed' => $element['#programmed'],
+      '#tree' => $element['#tree'],
+    );
+    $element['input']['#parents'][] = 'input';
+    unset($element['input']['#name'], $element['input']['#id']);
+    _form_generate_name_id($element['input']);
+    $element['input']['#process'][] = 'form_set_parent_value';
+    $element['#value'] = &$element['input']['#value'];
+  }
+  return $element;
+}
+
+/**
+ * Set parent value for textareas.
+ */
+function form_set_parent_value($element, $edit, &$form_state) {
+  $element_original = $element;
+  array_pop($element['#parents']);
+  form_set_value($element, $element['#value'], $form_state);
+  return $element_original;
+}
+
+/**
+ * Type with children only.
+ */
+function theme_children_only($element) {
+  return isset($element['#children']) ? $element['#children'] : '';
+}
+
+/**
  * Format a form item.
  *
  * @param $element
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.306
diff -u -p -u -r1.306 block.module
--- modules/block/block.module	15 May 2008 21:30:02 -0000	1.306
+++ modules/block/block.module	20 May 2008 12:51:58 -0000
@@ -308,19 +308,16 @@ function block_box_form($edit = array())
     '#required' => TRUE,
     '#weight' => -19,
   );
-  $form['body_field']['#weight'] = -17;
-  $form['body_field']['body'] = array(
+
+  $form['body'] = array(
     '#type' => 'textarea',
     '#title' => t('Block body'),
     '#default_value' => $edit['body'],
     '#rows' => 15,
     '#description' => t('The content of the block as shown to the user.'),
     '#weight' => -17,
+    '#input_format' => isset($edit['format']) ? $edit['format'] : FILTER_FORMAT_DEFAULT,
   );
-  if (!isset($edit['format'])) {
-    $edit['format'] = FILTER_FORMAT_DEFAULT;
-  }
-  $form['body_field']['format'] = filter_form($edit['format'], -16);
 
   return $form;
 }
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.633
diff -u -p -u -r1.633 comment.module
--- modules/comment/comment.module	14 May 2008 13:12:40 -0000	1.633
+++ modules/comment/comment.module	20 May 2008 12:52:00 -0000
@@ -1374,24 +1374,14 @@ function comment_form(&$form_state, $edi
     );
   }
 
-  if (!empty($edit['comment'])) {
-    $default = $edit['comment'];
-  }
-  else {
-    $default = '';
-  }
-
-  $form['comment_filter']['comment'] = array(
+  $form['comment'] = array(
     '#type' => 'textarea',
     '#title' => t('Comment'),
     '#rows' => 15,
-    '#default_value' => $default,
+    '#default_value' => !empty($edit['comment']) ? $edit['comment'] : '',
     '#required' => TRUE,
+    '#input_format' => isset($edit['format']) ? $edit['format'] : FILTER_FORMAT_DEFAULT,
   );
-  if (!isset($edit['format'])) {
-    $edit['format'] = FILTER_FORMAT_DEFAULT;
-  }
-  $form['comment_filter']['format'] = filter_form($edit['format']);
 
   $form['cid'] = array(
     '#type' => 'value',
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.213
diff -u -p -u -r1.213 filter.module
--- modules/filter/filter.module	6 May 2008 12:18:47 -0000	1.213
+++ modules/filter/filter.module	20 May 2008 12:52:01 -0000
@@ -470,7 +470,9 @@ function check_markup($text, $format = F
  * @return
  *   HTML for the form element.
  */
-function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = array('format')) {
+function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = NULL, $parents = NULL) {
+  $parents[] = 'format';
+
   $value = filter_resolve_format($value);
   $formats = filter_formats();
 
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.30
diff -u -p -u -r1.30 node.pages.inc
--- modules/node/node.pages.inc	14 Apr 2008 17:48:38 -0000	1.30
+++ modules/node/node.pages.inc	20 May 2008 12:52:02 -0000
@@ -289,10 +289,9 @@ function node_body_field(&$node, $label,
     '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
     '#rows' => 20,
     '#required' => ($word_count > 0),
+    '#input_format' => isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT,
   );
 
-  $form['format'] = filter_form($node->format);
-
   return $form;
 }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.602
diff -u -p -u -r1.602 system.module
--- modules/system/system.module	7 May 2008 19:17:50 -0000	1.602
+++ modules/system/system.module	20 May 2008 12:52:05 -0000
@@ -229,7 +229,7 @@ function system_elements() {
     '#cols' => 60,
     '#rows' => 5,
     '#resizable' => TRUE,
-    '#process' => array('form_expand_ahah'),
+    '#process' => array('form_expand_ahah', 'form_expand_format'),
   );
 
   $type['radios'] = array(
