Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.268 diff -u -p -r1.268 form.inc --- includes/form.inc 15 Mar 2008 11:02:47 -0000 1.268 +++ includes/form.inc 31 Mar 2008 11:41:13 -0000 @@ -1812,6 +1812,16 @@ function form_expand_ahah($element) { } /** + * Expand input format support. Add format selector. + */ +function form_expand_format($element) { + if (isset($element['#input_format'])) { + $element['format'] = filter_form($element['#input_format'], 10, $element['#parents']); + } + return $element; +} + +/** * Format a form item. * * @param $element @@ -2054,7 +2064,7 @@ function theme_textarea($element) { } _form_set_class($element, $class); - return theme('form_element', $element, ''); + return theme('form_element', $element, '') . (!empty($element['#children']) ? $element['#children'] : ''); } /** Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.301 diff -u -p -r1.301 block.module --- modules/block/block.module 21 Mar 2008 08:41:25 -0000 1.301 +++ modules/block/block.module 31 Mar 2008 11:41:17 -0000 @@ -318,19 +318,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.621 diff -u -p -r1.621 comment.module --- modules/comment/comment.module 23 Feb 2008 08:02:48 -0000 1.621 +++ modules/comment/comment.module 31 Mar 2008 11:41:17 -0000 @@ -1380,24 +1380,14 @@ function comment_form(&$form_state, $edi $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => !empty($edit['subject']) ? $edit['subject'] : ''); } - 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', '#value' => !empty($edit['cid']) ? $edit['cid'] : NULL); $form['pid'] = array('#type' => 'value', '#value' => !empty($edit['pid']) ? $edit['pid'] : NULL); Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.207 diff -u -p -r1.207 filter.module --- modules/filter/filter.module 13 Mar 2008 21:26:08 -0000 1.207 +++ modules/filter/filter.module 31 Mar 2008 11:41:18 -0000 @@ -473,7 +473,16 @@ 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) { + + // form_expand_format() adds a 'format' element, which is parent to radio + // buttons added in this function. Although then we would get a textarea + // child, which would result in the textarea not getting through. + // $parents[] = 'format'; + + // Hack, until we discuss this. + $parents = array('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.29 diff -u -p -r1.29 node.pages.inc --- modules/node/node.pages.inc 17 Feb 2008 19:29:07 -0000 1.29 +++ modules/node/node.pages.inc 31 Mar 2008 11:41:18 -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.593 diff -u -p -r1.593 system.module --- modules/system/system.module 11 Mar 2008 08:13:14 -0000 1.593 +++ modules/system/system.module 31 Mar 2008 11:41:19 -0000 @@ -180,7 +180,7 @@ function system_elements() { $type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_expand_ahah')); $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#process' => array('form_expand_ahah')); $type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm')); - $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_expand_ahah')); + $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE, '#process' => array('form_expand_ahah', 'form_expand_format')); $type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios')); $type['radio'] = array('#input' => TRUE, '#default_value' => NULL, '#process' => array('form_expand_ahah')); $type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes'), '#tree' => TRUE);