=== modified file 'includes/common.inc' --- includes/common.inc 2008-05-16 01:23:31 +0000 +++ includes/common.inc 2008-05-20 12:00:37 +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), + ), ); } === modified file 'includes/form.inc' --- includes/form.inc 2008-05-06 12:18:44 +0000 +++ includes/form.inc 2008-05-20 12:05:11 +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,42 @@ 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; +} + +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; +} + +function theme_children_only($element) { + return isset($element['#children']) ? $element['#children'] : ''; +} + +/** * Format a form item. * * @param $element === modified file 'modules/block/block.module' --- modules/block/block.module 2008-05-15 21:30:02 +0000 +++ modules/block/block.module 2008-05-20 10:07:00 +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; } === modified file 'modules/comment/comment.module' --- modules/comment/comment.module 2008-05-14 13:12:40 +0000 +++ modules/comment/comment.module 2008-05-20 10:07: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', === modified file 'modules/filter/filter.module' --- modules/filter/filter.module 2008-05-06 12:18:44 +0000 +++ modules/filter/filter.module 2008-05-20 11:36:35 +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(); === modified file 'modules/node/node.pages.inc' --- modules/node/node.pages.inc 2008-04-14 17:48:33 +0000 +++ modules/node/node.pages.inc 2008-05-20 10:07:00 +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; } === modified file 'modules/system/system.module' --- modules/system/system.module 2008-05-07 19:17:50 +0000 +++ modules/system/system.module 2008-05-20 11:32:10 +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(