Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.324
diff -u -p -r1.324 form.inc
--- includes/form.inc	14 Mar 2009 20:13:26 -0000	1.324
+++ includes/form.inc	25 Mar 2009 22:37:06 -0000
@@ -1866,7 +1866,8 @@ function form_process_radios($element) {
  * Add text format selector to text elements with the #text_format property.
  *
  * The #text_format property should be the ID of an text format, found in
- * {filter_format}.format, which gets passed to filter_form().
+ * {filter_format}.format, which gets passed to filter_form(). Alternatively,
+ * it can be an array of arguments for filter_form().
  *
  * If the property #text_format is set, the form element will be expanded into
  * two separate form elements, one holding the content of the element, and the
@@ -1882,6 +1883,12 @@ function form_process_radios($element) {
  *     '#title' => t('Body'),
  *     '#text_format' => isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT,
  *   );
+ *   // Example for passing an array to filter_form().
+ *   $form['body'] = array(
+ *     '#type' => 'textarea',
+ *     '#title' => t('Body'),
+ *     '#text_format' => array($node->format, NULL, 'custom_format_name'),
+ *   );
  * @endcode
  *
  * Becomes:
@@ -1920,14 +1927,22 @@ function form_process_text_format($eleme
     // parents that filter_form() expects.
     $element_parents = $element['#parents'];
     $element_name = array_pop($element_parents);
-    $element_parents[] = $element_name . '_format';
+    if (is_array($element['#text_format'])) {
+      list($format, $weight, $parent) = $element['#text_format'];
+      $element_parents[] = $parent;
+    }
+    else {
+      $format = $element['#text_format'];
+      $weight = 1;
+      $element_parents[] = $element_name . '_format';
+    }
 
     // We need to break references, otherwise form_builder recurses infinitely.
     $element['value'] = (array)$element;
     $element['#type'] = 'markup';
     $element['#theme'] = NULL;
     $element['#theme_wrapper'] = NULL;
-    $element['format'] = filter_form($element['#text_format'], 1, $element_parents);
+    $element['format'] = filter_form($format, $weight, $element_parents);
 
     // We need to clear the #text_format from the new child otherwise we
     // would get into an infinite loop.
