Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1074
diff -u -p -r1.1074 common.inc
--- includes/common.inc 3 Jan 2010 11:04:58 -0000 1.1074
+++ includes/common.inc 3 Jan 2010 16:13:39 -0000
@@ -5600,9 +5600,6 @@ function drupal_common_theme() {
'form_element_label' => array(
'render element' => 'element',
),
- 'text_format_wrapper' => array(
- 'render element' => 'element',
- ),
'vertical_tabs' => array(
'render element' => 'element',
),
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.424
diff -u -p -r1.424 form.inc
--- includes/form.inc 2 Jan 2010 23:30:53 -0000 1.424
+++ includes/form.inc 3 Jan 2010 21:22:09 -0000
@@ -1430,7 +1430,15 @@ function _form_builder_handle_input_elem
}
}
}
- form_set_value($element, $element['#value'], $form_state);
+ // Set the element's value in $form_state['values'], but only, if its key
+ // does not exist yet (a #value_callback may have already populated it).
+ $values = $form_state['values'];
+ foreach ($element['#parents'] as $key) {
+ $values = (isset($values[$key]) ? $values[$key] : NULL);
+ }
+ if (!isset($values)) {
+ form_set_value($element, $element['#value'], $form_state);
+ }
}
/**
@@ -2198,110 +2206,6 @@ 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().
- *
- * 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
- * other holding the text format selector. The original element is shifted into
- * a child element, but is otherwise unaltered, so that the format selector is
- * at the same level as the text field which it affects.
- *
- * For example:
- * @code
- * // A simple textarea, such as a node body.
- * $form['body'] = array(
- * '#type' => 'textarea',
- * '#title' => t('Body'),
- * '#text_format' => isset($node->format) ? $node->format : filter_default_format(),
- * );
- * @endcode
- *
- * Becomes:
- * @code
- * $form['body'] = array(
- * // Type switches to 'markup', as we're only interested in submitting the child elements.
- * '#type' => 'markup',
- * // 'value' holds the original element.
- * 'value' => array(
- * '#type' => 'textarea',
- * '#title' => t('Body'),
- * '#parents' => array('body'),
- * ),
- * // 'format' holds the text format selector.
- * 'format' => array(
- * '#parents' => array('body_format'),
- * ...
- * ),
- * );
- * @endcode
- *
- * And would result in:
- * @code
- * // Original, unaltered form element value.
- * $form_state['values']['body'] = 'Example content';
- * // Chosen text format.
- * $form_state['values']['body_format'] = 1;
- * @endcode
- *
- * @see system_element_info(), filter_form()
- */
-function form_process_text_format($element) {
- if (isset($element['#text_format'])) {
- // Determine the form element parents and element name to use for the input
- // format widget. This simulates the 'element' and 'element_format' pair of
- // parents that filter_form() expects.
- $element_parents = $element['#parents'];
- $element_name = array_pop($element_parents);
- $element_parents[] = $element_name . '_format';
-
- // We need to break references, otherwise form_builder recurses infinitely.
- $element['value'] = (array)$element;
- $element['value']['#weight'] = 0;
- unset($element['value']['#description']);
- $element['#type'] = 'markup';
- $element['#theme'] = NULL;
- $element['#theme_wrappers'] = array('text_format_wrapper');
- $element['format'] = filter_form($element['#text_format'], 1, $element_parents);
-
- // We need to clear the #text_format from the new child otherwise we
- // would get into an infinite loop.
- unset($element['value']['#text_format']);
- }
- return $element;
-}
-
-/**
- * Theme a text format form element.
- *
- * @param $variables
- * An associative array containing:
- * - element: An associative array containing the properties of the element.
- * Properties used: #children, #description
- *
- * @return
- * A string representing the form element.
- *
- * @ingroup themeable
- */
-function theme_text_format_wrapper($variables) {
- $element = $variables['element'];
- $output = '
' . "\n";
-
- $output .= $element['#children'] . "\n";
-
- if (!empty($element['#description'])) {
- $output .= '
' . $element['#description'] . "
\n";
- }
-
- $output .= "
\n";
-
- return $output;
-}
-
-/**
* Theme a checkbox form element.
*
* @param $variables
Index: misc/form.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/form.js,v
retrieving revision 1.13
diff -u -p -r1.13 form.js
--- misc/form.js 5 Dec 2009 15:04:33 -0000 1.13
+++ misc/form.js 8 Dec 2009 23:34:09 -0000
@@ -59,23 +59,6 @@ Drupal.behaviors.formUpdated = {
};
/**
- * Automatically display the guidelines of the selected text format.
- */
-Drupal.behaviors.filterGuidelines = {
- attach: function (context) {
- $('.filter-guidelines', context).once('filter-guidelines')
- .find('label').hide()
- .parents('.filter-wrapper').find('select.filter-list')
- .bind('change', function () {
- $(this).parents('.filter-wrapper')
- .find('.filter-guidelines-item').hide()
- .siblings('#filter-guidelines-' + this.value).show();
- })
- .change();
- }
-};
-
-/**
* Prepopulate form fields with information from the visitor cookie.
*/
Drupal.behaviors.fillUserInfoFromCookie = {
Index: modules/aggregator/aggregator.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.test,v
retrieving revision 1.36
diff -u -p -r1.36 aggregator.test
--- modules/aggregator/aggregator.test 2 Dec 2009 19:26:21 -0000 1.36
+++ modules/aggregator/aggregator.test 3 Jan 2010 23:37:45 -0000
@@ -254,7 +254,7 @@ EOF;
for ($i = 0; $i < 5; $i++) {
$edit = array();
$edit["title[$langcode][0][value]"] = $this->randomName();
- $edit["body[$langcode][0][value]"] = $this->randomName();
+ $edit["body[$langcode][0][value][value]"] = $this->randomName();
$this->drupalPost('node/add/article', $edit, t('Save'));
}
}
Index: modules/block/block.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v
retrieving revision 1.67
diff -u -p -r1.67 block.admin.inc
--- modules/block/block.admin.inc 14 Dec 2009 13:32:53 -0000 1.67
+++ modules/block/block.admin.inc 3 Jan 2010 16:13:40 -0000
@@ -468,7 +468,7 @@ function block_add_block_form_submit($fo
->fields(array(
'body' => $form_state['values']['body'],
'info' => $form_state['values']['info'],
- 'format' => $form_state['values']['body_format'],
+ 'format' => $form_state['values']['format'],
))
->execute();
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.404
diff -u -p -r1.404 block.module
--- modules/block/block.module 18 Dec 2009 07:17:50 -0000 1.404
+++ modules/block/block.module 3 Jan 2010 21:23:57 -0000
@@ -421,10 +421,10 @@ function block_custom_block_form($edit =
);
$form['body_field']['#weight'] = -17;
$form['body_field']['body'] = array(
- '#type' => 'textarea',
+ '#type' => 'filter_format',
'#title' => t('Block body'),
'#default_value' => $edit['body'],
- '#text_format' => isset($edit['format']) ? $edit['format'] : filter_default_format(),
+ '#format' => isset($edit['format']) ? $edit['format'] : NULL,
'#rows' => 15,
'#description' => t('The content of the block as shown to the user.'),
'#required' => TRUE,
@@ -453,7 +453,7 @@ function block_custom_block_save($edit,
->fields(array(
'body' => $edit['body'],
'info' => $edit['info'],
- 'format' => $edit['body_format'],
+ 'format' => $edit['format'],
))
->condition('bid', $delta)
->execute();
Index: modules/block/block.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.test,v
retrieving revision 1.33
diff -u -p -r1.33 block.test
--- modules/block/block.test 1 Dec 2009 22:30:30 -0000 1.33
+++ modules/block/block.test 3 Jan 2010 23:09:33 -0000
@@ -41,7 +41,7 @@ class BlockTestCase extends DrupalWebTes
$custom_block = array();
$custom_block['info'] = $this->randomName(8);
$custom_block['title'] = $this->randomName(8);
- $custom_block['body'] = $this->randomName(32);
+ $custom_block['body[value]'] = $this->randomName(32);
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
// Confirm that the custom block has been created, and then query the created bid.
@@ -78,8 +78,8 @@ class BlockTestCase extends DrupalWebTes
$custom_block = array();
$custom_block['info'] = $this->randomName(8);
$custom_block['title'] = $this->randomName(8);
- $custom_block['body'] = 'Full HTML
';
- $custom_block['body_format'] = 2;
+ $custom_block['body[value]'] = 'Full HTML
';
+ $custom_block['body[format]'] = 2;
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
// Set the created custom block to a specific region.
@@ -119,7 +119,7 @@ class BlockTestCase extends DrupalWebTes
$custom_block = array();
$custom_block['info'] = $this->randomName(8);
$custom_block['title'] = $title;
- $custom_block['body'] = $this->randomName(32);
+ $custom_block['body[value]'] = $this->randomName(32);
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
Index: modules/blog/blog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.test,v
retrieving revision 1.24
diff -u -p -r1.24 blog.test
--- modules/blog/blog.test 3 Dec 2009 20:21:50 -0000 1.24
+++ modules/blog/blog.test 3 Jan 2010 23:10:38 -0000
@@ -153,7 +153,7 @@ class BlogTestCase extends DrupalWebTest
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
- $edit["body[$langcode][0][value]"] = $this->randomName(256);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(256);
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title[$langcode][0][value]"])), t('Blog node was edited'));
Index: modules/book/book.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.test,v
retrieving revision 1.21
diff -u -p -r1.21 book.test
--- modules/book/book.test 2 Dec 2009 19:26:21 -0000 1.21
+++ modules/book/book.test 3 Jan 2010 23:11:06 -0000
@@ -174,7 +174,7 @@ class BookTestCase extends DrupalWebTest
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
- $edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
+ $edit["body[$langcode][0][value][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
if ($parent !== NULL) {
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.822
diff -u -p -r1.822 comment.module
--- modules/comment/comment.module 26 Dec 2009 16:50:08 -0000 1.822
+++ modules/comment/comment.module 3 Jan 2010 21:24:48 -0000
@@ -1302,7 +1302,7 @@ function comment_save($comment) {
'changed' => $comment->changed,
'subject' => $comment->subject,
'comment' => $comment->comment,
- 'format' => $comment->comment_format,
+ 'format' => $comment->format,
'uid' => $comment->uid,
'name' => $comment->name,
'mail' => $comment->mail,
@@ -1378,7 +1378,7 @@ function comment_save($comment) {
'uid' => $comment->uid,
'subject' => $comment->subject,
'comment' => $comment->comment,
- 'format' => $comment->comment_format,
+ 'format' => $comment->format,
'hostname' => ip_address(),
'created' => $comment->created,
'changed' => $comment->changed,
@@ -1822,10 +1822,10 @@ function comment_form($form, &$form_stat
'#access' => variable_get('comment_subject_field_' . $node->type, 1) == 1,
);
$form['comment'] = array(
- '#type' => 'textarea',
+ '#type' => 'filter_format',
'#title' => t('Comment'),
'#default_value' => $comment->comment,
- '#text_format' => isset($comment->format) ? $comment->format : filter_default_format(),
+ '#format' => isset($comment->format) ? $comment->format : NULL,
'#required' => TRUE,
'#rows' => 15,
);
@@ -1887,8 +1887,6 @@ function comment_preview($comment) {
$node = node_load($comment->nid);
if (!form_get_errors()) {
- $comment->format = $comment->comment_format;
-
// Attach the user and time information.
if (!empty($comment->name)) {
$account = user_load_by_name($comment->name);
@@ -2015,7 +2013,7 @@ function comment_submit($comment) {
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
- $comment['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment['comment'], $comment['comment_format'])))), 29, TRUE);
+ $comment['subject'] = truncate_utf8(trim(decode_entities(strip_tags(check_markup($comment['comment'], $comment['format'])))), 29, TRUE);
// Edge cases where the comment body is populated only by HTML tags will
// require a default subject.
if ($comment['subject'] == '') {
Index: modules/comment/comment.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v
retrieving revision 1.33
diff -u -p -r1.33 comment.pages.inc
--- modules/comment/comment.pages.inc 27 Dec 2009 03:43:45 -0000 1.33
+++ modules/comment/comment.pages.inc 3 Jan 2010 16:13:41 -0000
@@ -108,7 +108,6 @@ function comment_reply($node, $pid = NUL
*/
function comment_approve($comment) {
$comment->status = COMMENT_PUBLISHED;
- $comment->comment_format = $comment->format;
comment_save($comment);
drupal_set_message(t('Comment approved.'));
Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.59
diff -u -p -r1.59 comment.test
--- modules/comment/comment.test 16 Dec 2009 19:53:53 -0000 1.59
+++ modules/comment/comment.test 3 Jan 2010 23:08:55 -0000
@@ -29,7 +29,7 @@ class CommentHelperCase extends DrupalWe
*/
function postComment($node, $comment, $subject = '', $contact = NULL) {
$edit = array();
- $edit['comment'] = $comment;
+ $edit['comment[value]'] = $comment;
$preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL);
$subject_mode = variable_get('comment_subject_field_article', 1);
@@ -418,17 +418,17 @@ class CommentPreviewTest extends Comment
$this->drupalLogin($this->web_user);
$edit = array();
$edit['subject'] = $this->randomName(8);
- $edit['comment'] = $this->randomName(16);
+ $edit['comment[value]'] = $this->randomName(16);
$this->drupalPost('node/' . $this->node->nid, $edit, t('Preview'));
// Check that the preview is displaying the title and body.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
- $this->assertText($edit['comment'], t('Comment displayed.'));
+ $this->assertText($edit['comment[value]'], t('Comment displayed.'));
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
- $this->assertFieldByName('comment', $edit['comment'], t('Comment field displayed.'));
+ $this->assertFieldByName('comment[value]', $edit['comment[value]'], t('Comment field displayed.'));
}
/**
@@ -444,23 +444,23 @@ class CommentPreviewTest extends Comment
$edit = array();
$edit['subject'] = $this->randomName(8);
- $edit['comment'] = $this->randomName(16);
+ $edit['comment[value]'] = $this->randomName(16);
$edit['name'] = $web_user->name;
$edit['date'] = '2008-03-02 17:23 +0300';
$expected_date = format_date(strtotime($edit['date']));
- $comment = $this->postComment($this->node, $edit['subject'], $edit['comment'], TRUE);
+ $comment = $this->postComment($this->node, $edit['subject'], $edit['comment[value]'], TRUE);
$this->drupalPost('comment/' . $comment->id . '/edit', $edit, t('Preview'));
// Check that the preview is displaying the subject, comment, author and date correctly.
$this->assertTitle(t('Preview comment | Drupal'), t('Page title is "Preview comment".'));
$this->assertText($edit['subject'], t('Subject displayed.'));
- $this->assertText($edit['comment'], t('Comment displayed.'));
+ $this->assertText($edit['comment[value]'], t('Comment displayed.'));
$this->assertText($edit['name'], t('Author displayed.'));
$this->assertText($expected_date, t('Date displayed.'));
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject', $edit['subject'], t('Subject field displayed.'));
- $this->assertFieldByName('comment', $edit['comment'], t('Comment field displayed.'));
+ $this->assertFieldByName('comment[value]', $edit['comment[value]'], t('Comment field displayed.'));
$this->assertFieldByName('name', $edit['name'], t('Author field displayed.'));
$this->assertFieldByName('date', $edit['date'], t('Date field displayed.'));
}
@@ -566,7 +566,7 @@ class CommentAnonymous extends CommentHe
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->assertText('You are not authorized to view comments', t('Error attempting to post comment.'));
$this->assertNoFieldByName('subject', '', t('Subject field not found.'));
- $this->assertNoFieldByName('comment', '', t('Comment field not found.'));
+ $this->assertNoFieldByName('comment[value]', '', t('Comment field not found.'));
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE,
Index: modules/dblog/dblog.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v
retrieving revision 1.31
diff -u -p -r1.31 dblog.test
--- modules/dblog/dblog.test 23 Dec 2009 23:07:16 -0000 1.31
+++ modules/dblog/dblog.test 3 Jan 2010 23:14:47 -0000
@@ -333,7 +333,7 @@ class DBLogTestCase extends DrupalWebTes
default:
$content = array(
"title[$langcode][0][value]" => $this->randomName(8),
- "body[$langcode][0][value]" => $this->randomName(32),
+ "body[$langcode][0][value][value]" => $this->randomName(32),
);
break;
}
@@ -358,7 +358,7 @@ class DBLogTestCase extends DrupalWebTes
default:
$langcode = LANGUAGE_NONE;
$content = array(
- "body[$langcode][0][value]" => $this->randomName(32),
+ "body[$langcode][0][value][value]" => $this->randomName(32),
);
break;
}
Index: modules/field/modules/text/text.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.module,v
retrieving revision 1.45
diff -u -p -r1.45 text.module
--- modules/field/modules/text/text.module 21 Dec 2009 13:47:32 -0000 1.45
+++ modules/field/modules/text/text.module 3 Jan 2010 21:25:47 -0000
@@ -553,11 +553,10 @@ function text_field_widget_form(&$form,
break;
}
+ // Conditionally alter the form element's type if text processing is enabled.
if ($instance['settings']['text_processing']) {
- $element['value']['#text_format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : filter_default_format();
- $element['#type'] = 'markup';
- $element['#input'] = TRUE;
- $element['#value_callback'] = 'text_field_widget_formatted_text_value';
+ $element['value']['#type'] = 'filter_format';
+ $element['value']['#format'] = isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL;
}
return $element;
@@ -580,19 +579,3 @@ function text_field_widget_error($elemen
form_error($error_element, $error['message']);
}
-/**
- * Form element #value_callback to re-assign text format value for a formatted text widget.
- *
- * #text_format puts the format into 'value_format', while we need it in
- * 'format'.
- */
-function text_field_widget_formatted_text_value($element, $edit = FALSE, &$form_state) {
- if ($edit !== FALSE) {
- // The format selector uses #access = FALSE if only one format is
- // available. In this case, we don't receive its value, and need to
- // manually set it.
- $edit['format'] = !empty($edit['value_format']) ? $edit['value_format'] : filter_default_format();
- unset($edit['value_format']);
- return $edit;
- }
-}
Index: modules/field/modules/text/text.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/field/modules/text/text.test,v
retrieving revision 1.17
diff -u -p -r1.17 text.test
--- modules/field/modules/text/text.test 13 Dec 2009 09:04:55 -0000 1.17
+++ modules/field/modules/text/text.test 3 Jan 2010 23:32:28 -0000
@@ -101,13 +101,13 @@ class TextFieldTestCase extends DrupalWe
// Display creation form.
$this->drupalGet('test-entity/add/test-bundle');
- $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
- $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed'));
+ $this->assertFieldByName("{$this->field_name}[$langcode][0][value][value]", '', t('Widget is displayed'));
+ $this->assertNoFieldByName("{$this->field_name}[$langcode][0][value][format]", '1', t('Format selector is not displayed'));
// Submit with some value.
$value = $this->randomName();
$edit = array(
- "{$this->field_name}[$langcode][0][value]" => $value,
+ "{$this->field_name}[$langcode][0][value][value]" => $value,
);
$this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/(\d+)/edit|', $this->url, $match);
@@ -165,13 +165,13 @@ class TextFieldTestCase extends DrupalWe
// Display the creation form. Since the user only has access to one format,
// no format selector will be displayed.
$this->drupalGet('test-entity/add/test-bundle');
- $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
- $this->assertNoFieldByName("{$this->field_name}[$langcode][0][value_format]", '', t('Format selector is not displayed'));
+ $this->assertFieldByName("{$this->field_name}[$langcode][0][value][value]", '', t('Widget is displayed'));
+ $this->assertNoFieldByName("{$this->field_name}[$langcode][0][value][format]", '', t('Format selector is not displayed'));
// Submit with data that should be filtered.
$value = '' . $this->randomName() . '';
$edit = array(
- "{$this->field_name}[$langcode][0][value]" => $value,
+ "{$this->field_name}[$langcode][0][value][value]" => $value,
);
$this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/(\d+)/edit|', $this->url, $match);
@@ -201,12 +201,12 @@ class TextFieldTestCase extends DrupalWe
// Display edition form.
// We should now have a 'text format' selector.
$this->drupalGet('test-entity/' . $id . '/edit');
- $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
- $this->assertFieldByName("{$this->field_name}[$langcode][0][value_format]", '', t('Format selector is displayed'));
+ $this->assertFieldByName("{$this->field_name}[$langcode][0][value][value]", '', t('Widget is displayed'));
+ $this->assertFieldByName("{$this->field_name}[$langcode][0][value][format]", '', t('Format selector is displayed'));
// Edit and change the text format to the new one that was created.
$edit = array(
- "{$this->field_name}[$langcode][0][value_format]" => $format_id,
+ "{$this->field_name}[$langcode][0][value][format]" => $format_id,
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated'));
Index: modules/filter/filter.css
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.css,v
retrieving revision 1.2
diff -u -p -r1.2 filter.css
--- modules/filter/filter.css 14 Dec 2009 13:32:53 -0000 1.2
+++ modules/filter/filter.css 3 Jan 2010 16:13:42 -0000
@@ -11,7 +11,6 @@
}
.filter-wrapper .form-item {
float: left;
- margin: 0;
padding: 0 0 0.5em 1.5em;
}
.filter-wrapper .form-item label {
Index: modules/filter/filter.js
===================================================================
RCS file: modules/filter/filter.js
diff -N modules/filter/filter.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ modules/filter/filter.js 7 Nov 2009 22:46:56 -0000
@@ -0,0 +1,21 @@
+// $Id: form.js,v 1.12 2009/10/16 16:37:00 dries Exp $
+(function ($) {
+
+/**
+ * Automatically display the guidelines of the selected text format.
+ */
+Drupal.behaviors.filterGuidelines = {
+ attach: function (context) {
+ $('.filter-guidelines', context).once('filter-guidelines')
+ .find('label').hide()
+ .parents('.filter-wrapper').find('select.filter-list')
+ .bind('change', function () {
+ $(this).parents('.filter-wrapper')
+ .find('.filter-guidelines-item').hide()
+ .siblings('#filter-guidelines-' + this.value).show();
+ })
+ .change();
+ }
+};
+
+})(jQuery);
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.314
diff -u -p -r1.314 filter.module
--- modules/filter/filter.module 28 Dec 2009 21:52:13 -0000 1.314
+++ modules/filter/filter.module 4 Jan 2010 04:16:31 -0000
@@ -54,6 +54,9 @@ function filter_theme() {
'variables' => array('tips' => NULL, 'long' => FALSE),
'file' => 'filter.pages.inc',
),
+ 'filter_format_wrapper' => array(
+ 'render element' => 'element',
+ ),
'filter_tips_more_info' => array(
'variables' => array(),
),
@@ -64,6 +67,20 @@ function filter_theme() {
}
/**
+ * Implements hook_element_info().
+ *
+ * @see filter_process_format()
+ */
+function filter_element_info() {
+ $type['filter_format'] = array(
+ '#process' => array('filter_process_format'),
+ '#base_type' => 'textarea',
+ '#theme_wrappers' => array('filter_format_wrapper'),
+ );
+ return $type;
+}
+
+/**
* Implements hook_menu().
*/
function filter_menu() {
@@ -653,71 +670,188 @@ function check_markup($text, $format_id
}
/**
- * Generates a selector for choosing a format in a form.
+ * Expands an element into a base element with text format selector attached.
*
- * @param $selected_format
- * The ID of the format that is currently selected; uses the default format
- * for the current user if not provided.
- * @param $weight
- * The weight of the form element within the form.
- * @param $parents
- * The parents array of the element. Required when defining multiple text
- * formats on a single form or having a different parent than 'format'.
+ * The form element will be expanded into two separate form elements, one
+ * holding the original element, and the other holding the text format selector:
+ * - value: Holds the original element, having its #type changed to the value of
+ * #base_type or 'textarea' by default.
+ * - format: Holds the text format fieldset and the text format selection, using
+ * the text format id specified in #format or the user's default format by
+ * default, if NULL.
+ *
+ * Since most modules expect the value of the new 'format' element *next* to the
+ * original element, filter_process_format() applies a #value_callback to both
+ * the 'value' and the 'format' element by default to let the submitted form
+ * values appear as if they were located on the same level.
+ * For example, considering the input values:
+ * @code
+ * $form_state['input']['body']['value'] = 'foo';
+ * $form_state['input']['body']['format'] = 'foo';
+ * @endcode
+ * The value callbacks will process them into:
+ * @code
+ * $form_state['values']['body'] = 'foo';
+ * $form_state['values']['format'] = 'foo';
+ * @endcode
+ *
+ * If multiple text format-enabled elements are required on the same level of
+ * the form structure, modules can set custom #parents on the original element.
+ * Alternatively, the #value_callback properties may be unset through a
+ * subsequent #process callback. If no custom processing occurs, then the
+ * submitted form values will appear like in the $form_state['input'] array
+ * above.
+ *
+ * @see filter_form_value_callback_value()
+ * @see filter_form_value_callback_format()
+ *
+ * @param $element
+ * The form element to process. Properties used:
+ * - #base_type: The form element #type to use for the 'value' element.
+ * 'textarea' by default.
+ * - #format: (optional) The text format id to preselect. If 0, NULL, or not
+ * set, the default format for the current user will be used.
*
* @return
- * Form API array for the form element.
- *
- * @ingroup forms
+ * The expanded element.
*/
-function filter_form($selected_format = NULL, $weight = NULL, $parents = array('format')) {
+function filter_process_format($element) {
global $user;
- // Use the default format for this user if none was selected.
- if (empty($selected_format)) {
- $selected_format = filter_default_format($user);
- }
-
- // Get a list of formats that the current user has access to.
- $formats = filter_formats($user);
+ // Ensure that children appear as subkeys of this element.
+ $element['#tree'] = TRUE;
- drupal_add_js('misc/form.js');
- drupal_add_css(drupal_get_path('module', 'filter') . '/filter.css');
- $element_id = drupal_html_id('edit-' . implode('-', $parents));
+ // Move this element into sub-element 'value'. Break references and remove
+ // this #process function to prevent form_builder() to recurse infinitely.
+ $element['value'] = (array) $element;
+
+ // Make form_builder() regenerate child properties.
+ unset($element['value']['#parents'], $element['value']['#process'], $element['value']['#theme_wrappers']);
+ // Description is handled by theme_filter_format_wrapper().
+ unset($element['value']['#description']);
+ // Ensure proper ordering of children.
+ unset($element['value']['#weight']);
+ // Unset properties already processed for the parent element.
+ unset($element['value']['#prefix'], $element['value']['#suffix'], $element['value']['#attached']);
+
+ $element['value']['#type'] = $element['#base_type'];
+ $element['value'] += element_info($element['#base_type']);
+ $element['value']['#value_callback'] = 'filter_form_value_callback_value';
+
+ // Turn original element into a text format wrapper.
+ $path = drupal_get_path('module', 'filter');
+ $element['#attached']['js'][] = $path . '/filter.js';
+ $element['#attached']['css'][] = $path . '/filter.css';
- $form = array(
+ // Setup child container for the text format widget.
+ $element['format'] = array(
'#type' => 'fieldset',
- '#weight' => $weight,
'#attributes' => array('class' => array('filter-wrapper')),
);
- $form['format_guidelines'] = array(
- '#prefix' => '',
- '#suffix' => '
',
- '#weight' => 2,
+
+ // Prepare text format guidelines.
+ $element['format']['guidelines'] = array(
+ '#type' => 'container',
+ '#attributes' => array('class' => array('filter-guidelines')),
+ '#weight' => 20,
);
+ // Get a list of formats that the current user has access to.
+ $formats = filter_formats($user);
foreach ($formats as $format) {
$options[$format->format] = $format->name;
- $form['format_guidelines'][$format->format] = array(
- '#markup' => theme('filter_guidelines', array('format' => $format)),
+ $element['format']['guidelines'][$format->format] = array(
+ '#theme' => 'filter_guidelines',
+ '#format' => $format,
);
}
- $form['format'] = array(
+
+ // Use the default format for this user if none was selected.
+ if (empty($element['#format'])) {
+ $element['#format'] = filter_default_format($user);
+ }
+ $element['format']['format'] = array(
'#type' => 'select',
'#title' => t('Text format'),
'#options' => $options,
- '#default_value' => $selected_format,
- '#parents' => $parents,
+ '#default_value' => $element['#format'],
'#access' => count($formats) > 1,
- '#id' => $element_id,
+ '#weight' => 10,
'#attributes' => array('class' => array('filter-list')),
+ '#parents' => array_merge($element['#parents'], array('format')),
+ '#value_callback' => 'filter_form_value_callback_format',
);
- $form['format_help'] = array(
- '#prefix' => '',
- '#markup' => theme('filter_tips_more_info'),
- '#suffix' => '
',
- '#weight' => 1,
+
+ $element['format']['help'] = array(
+ '#type' => 'container',
+ '#theme' => 'filter_tips_more_info',
+ '#attributes' => array('class' => array('filter-help')),
+ '#weight' => 0,
);
- return $form;
+ return $element;
+}
+
+/**
+ * Form element #value_callback for 'value' element in expanded #type 'filter_format'.
+ */
+function filter_form_value_callback_value($element, $input, &$form_state) {
+ $parents = $element['#parents'];
+ array_pop($parents);
+ if ($input !== FALSE) {
+ form_set_value(array('#parents' => $parents), $input, $form_state);
+ return $input;
+ }
+ // Return #default_value of original element if #access is FALSE.
+ else {
+ $value = (isset($element['#default_value']) ? $element['#default_value'] : '');
+ form_set_value(array('#parents' => $parents), $value, $form_state);
+ return $value;
+ }
+}
+
+/**
+ * Form element #value_callback for 'format' element in expanded #type 'filter_format'.
+ */
+function filter_form_value_callback_format($element, $input, &$form_state) {
+ $parents = $element['#parents'];
+ array_pop($parents);
+ array_pop($parents);
+ $parents[] = 'format';
+ if ($input !== FALSE) {
+ form_set_value(array('#parents' => $parents), $input, $form_state);
+ return $input;
+ }
+ // Return #default_value of original element if #access is FALSE.
+ else {
+ $value = (isset($element['#default_value']) ? $element['#default_value'] : '');
+ form_set_value(array('#parents' => $parents), $value, $form_state);
+ return $value;
+ }
+}
+
+/**
+ * Render a text format-enabled form element.
+ *
+ * @param $variables
+ * An associative array containing:
+ * - element: An associative array containing the properties of the element.
+ * Properties used: #children, #description
+ *
+ * @return
+ * A string representing the form element.
+ *
+ * @ingroup themeable
+ */
+function theme_filter_format_wrapper($variables) {
+ $element = $variables['element'];
+ $output = '';
+ $output .= $element['#children'];
+ if (!empty($element['#description'])) {
+ $output .= '
' . $element['#description'] . '
';
+ }
+ $output .= "
\n";
+
+ return $output;
}
/**
Index: modules/filter/filter.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v
retrieving revision 1.53
diff -u -p -r1.53 filter.test
--- modules/filter/filter.test 14 Dec 2009 13:32:53 -0000 1.53
+++ modules/filter/filter.test 3 Jan 2010 23:18:58 -0000
@@ -291,8 +291,8 @@ class FilterAdminTestCase extends Drupal
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
- $edit["body[$langcode][0][value]"] = $text;
- $edit["body[$langcode][0][value_format]"] = $filtered;
+ $edit["body[$langcode][0][value][value]"] = $text;
+ $edit["body[$langcode][0][value][format]"] = $filtered;
$this->drupalPost('node/add/page', $edit, t('Save'));
$this->assertRaw(t('Page %title has been created.', array('%title' => $edit["title[$langcode][0][value]"])), t('Filtered node created.'));
@@ -304,7 +304,7 @@ class FilterAdminTestCase extends Drupal
// Use plain text and see if it escapes all tags, whether allowed or not.
$edit = array();
- $edit["body[$langcode][0][value_format]"] = $plain;
+ $edit["body[$langcode][0][value][format]"] = $plain;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->nid);
$this->assertText(check_plain($text), t('The "Plain text" text format escapes all HTML tags.'));
@@ -1178,9 +1178,9 @@ class FilterHooksTestCase extends Drupal
$custom_block = array();
$custom_block['info'] = $this->randomName(8);
$custom_block['title'] = $this->randomName(8);
- $custom_block['body'] = $this->randomName(32);
+ $custom_block['body[value]'] = $this->randomName(32);
// Use the format created.
- $custom_block['body_format'] = $format_id;
+ $custom_block['body[format]'] = $format_id;
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
$this->assertText(t('The block has been created.'), t('New block successfully created.'));
Index: modules/forum/forum.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.test,v
retrieving revision 1.43
diff -u -p -r1.43 forum.test
--- modules/forum/forum.test 2 Dec 2009 19:26:22 -0000 1.43
+++ modules/forum/forum.test 3 Jan 2010 23:22:47 -0000
@@ -78,7 +78,7 @@ class ForumTestCase extends DrupalWebTes
// Test adding a comment to a forum topic.
$node = $this->createForumTopic($this->forum, FALSE);
- $this->drupalPost("node/$node->nid", array('comment' => $this->randomName()), t('Save'));
+ $this->drupalPost("node/$node->nid", array('comment[value]' => $this->randomName()), t('Save'));
$this->assertResponse(200);
// Test editing a forum topic that has a comment.
@@ -147,7 +147,7 @@ class ForumTestCase extends DrupalWebTes
$edit = array(
'name' => $title,
- 'description' => $description,
+ 'description[value]' => $description,
'machine_name' => drupal_strtolower(drupal_substr($this->randomName(), 3, 9)),
);
@@ -189,7 +189,7 @@ class ForumTestCase extends DrupalWebTes
$edit = array(
'name' => $name,
- 'description' => $description,
+ 'description[value]' => $description,
'parent[0]' => $parent,
'weight' => '0',
);
@@ -266,7 +266,7 @@ class ForumTestCase extends DrupalWebTes
$langcode = LANGUAGE_NONE;
$edit = array(
"title[$langcode][0][value]" => $title,
- "body[$langcode][0][value]" => $body,
+ "body[$langcode][0][value][value]" => $body,
"taxonomy_forums[$langcode]" => $tid,
);
@@ -355,7 +355,7 @@ class ForumTestCase extends DrupalWebTes
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'node/' . $node->nid;
- $edit["body[$langcode][0][value]"] = $this->randomName(256);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(256);
// Assume the topic is initially associated with $forum.
$edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid'];
$edit['shadow'] = TRUE;
Index: modules/locale/locale.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.test,v
retrieving revision 1.56
diff -u -p -r1.56 locale.test
--- modules/locale/locale.test 26 Dec 2009 16:50:09 -0000 1.56
+++ modules/locale/locale.test 3 Jan 2010 23:25:02 -0000
@@ -1651,7 +1651,7 @@ class LocaleMultilingualFieldsFunctional
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
$title_value = $this->randomName(8);
- $body_key = "body[$langcode][0][value]";
+ $body_key = "body[$langcode][0][value][value]";
$body_value = $this->randomName(16);
// Create node to edit.
@@ -1690,7 +1690,7 @@ class LocaleMultilingualFieldsFunctional
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
$title_value = $this->randomName(8);
- $body_key = "body[$langcode][0][value]";
+ $body_key = "body[$langcode][0][value][value]";
$body_value = $this->randomName(16);
// Create node to edit.
Index: modules/menu/menu.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.test,v
retrieving revision 1.30
diff -u -p -r1.30 menu.test
--- modules/menu/menu.test 2 Jan 2010 19:25:20 -0000 1.30
+++ modules/menu/menu.test 3 Jan 2010 23:23:58 -0000
@@ -558,7 +558,7 @@ class MenuNodeTestCase extends DrupalWeb
$language = LANGUAGE_NONE;
$edit = array(
"title[$language][0][value]" => $node_title,
- "body[$language][0][value]" => $this->randomString(),
+ "body[$language][0][value][value]" => $this->randomString(),
);
$this->drupalPost('node/add/page', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($node_title);
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.61
diff -u -p -r1.61 node.test
--- modules/node/node.test 29 Dec 2009 19:14:27 -0000 1.61
+++ modules/node/node.test 3 Jan 2010 23:12:26 -0000
@@ -188,7 +188,7 @@ class PageEditTestCase extends DrupalWeb
function testPageEdit() {
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
- $body_key = "body[$langcode][0][value]";
+ $body_key = "body[$langcode][0][value][value]";
// Create node to edit.
$edit = array();
$edit[$title_key] = $this->randomName(8);
@@ -270,7 +270,7 @@ class PagePreviewTestCase extends Drupal
function testPagePreview() {
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
- $body_key = "body[$langcode][0][value]";
+ $body_key = "body[$langcode][0][value][value]";
// Fill in node creation form and preview node.
$edit = array();
@@ -294,7 +294,7 @@ class PagePreviewTestCase extends Drupal
function testPagePreviewWithRevisions() {
$langcode = LANGUAGE_NONE;
$title_key = "title[$langcode][0][value]";
- $body_key = "body[$langcode][0][value]";
+ $body_key = "body[$langcode][0][value][value]";
// Force revision on page content.
variable_set('node_options_page', array('status', 'revision'));
@@ -344,7 +344,7 @@ class NodeCreationTestCase extends Drupa
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName(8);
- $edit["body[$langcode][0][value]"] = $this->randomName(16);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the page has been created.
@@ -363,7 +363,7 @@ class NodeCreationTestCase extends Drupa
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = 'testing_transaction_exception';
- $edit["body[$langcode][0][value]"] = $this->randomName(16);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
if (Database::getConnection()->supportsTransactions()) {
@@ -568,7 +568,7 @@ class NodePostSettingsTestCase extends D
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName(8);
- $edit["body[$langcode][0][value]"] = $this->randomName(16);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
@@ -590,7 +590,7 @@ class NodePostSettingsTestCase extends D
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName(8);
- $edit["body[$langcode][0][value]"] = $this->randomName(16);
+ $edit["body[$langcode][0][value][value]"] = $this->randomName(16);
$this->drupalPost('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
Index: modules/path/path.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/path/path.test,v
retrieving revision 1.29
diff -u -p -r1.29 path.test
--- modules/path/path.test 9 Dec 2009 19:22:04 -0000 1.29
+++ modules/path/path.test 3 Jan 2010 23:27:01 -0000
@@ -277,7 +277,7 @@ class PathLanguageTestCase extends Drupa
$this->clickLink(t('add translation'));
$edit = array();
$langcode = 'fr';
- $edit["body[$langcode][0][value]"] = $this->randomName();
+ $edit["body[$langcode][0][value][value]"] = $this->randomName();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
$edit['path[alias]'] = $this->randomName();
Index: modules/php/php.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/php/php.test,v
retrieving revision 1.20
diff -u -p -r1.20 php.test
--- modules/php/php.test 3 Dec 2009 15:33:42 -0000 1.20
+++ modules/php/php.test 8 Dec 2009 23:44:59 -0000
@@ -77,7 +77,7 @@ class PHPFilterTestCase extends PHPTestC
// Change filter to PHP filter and see that PHP code is evaluated.
$edit = array();
$langcode = LANGUAGE_NONE;
- $edit["body[$langcode][0][value_format]"] = $this->php_code_format;
+ $edit["body[$langcode][0][format]"] = $this->php_code_format;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Page %title has been updated.', array('%title' => $node->title[LANGUAGE_NONE][0]['value'])), t('PHP code filter turned on.'));
Index: modules/search/search.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.test,v
retrieving revision 1.46
diff -u -p -r1.46 search.test
--- modules/search/search.test 2 Jan 2010 10:45:34 -0000 1.46
+++ modules/search/search.test 3 Jan 2010 23:27:44 -0000
@@ -385,7 +385,7 @@ class SearchRankingTestCase extends Drup
$this->refreshVariables();
// Add a comment to one of the nodes.
- $edit = array('subject' => 'my comment title', 'comment' => 'some random comment');
+ $edit = array('subject' => 'my comment title', 'comment[value]' => 'some random comment');
$this->drupalGet('comment/reply/' . $nodes['comments'][1]->nid);
$this->drupalPost(NULL, $edit, t('Preview'));
$this->drupalPost(NULL, $edit, t('Save'));
@@ -523,7 +523,7 @@ class SearchCommentTestCase extends Drup
$edit_comment = array(
'subject' => $this->randomName(2),
'comment' => '' . $comment_body . '
',
- 'comment_format' => 2,
+ 'format' => 2,
);
$this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save'));
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.863
diff -u -p -r1.863 system.module
--- modules/system/system.module 3 Jan 2010 14:57:50 -0000 1.863
+++ modules/system/system.module 3 Jan 2010 16:13:47 -0000
@@ -353,7 +353,7 @@ function system_element_info() {
'#size' => 60,
'#maxlength' => 128,
'#autocomplete_path' => FALSE,
- '#process' => array('form_process_text_format', 'ajax_process_form'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'textfield',
'#theme_wrappers' => array('form_element'),
);
@@ -375,7 +375,7 @@ function system_element_info() {
'#cols' => 60,
'#rows' => 5,
'#resizable' => TRUE,
- '#process' => array('form_process_text_format', 'ajax_process_form'),
+ '#process' => array('ajax_process_form'),
'#theme' => 'textarea',
'#theme_wrappers' => array('form_element'),
);
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.99
diff -u -p -r1.99 system.test
--- modules/system/system.test 24 Dec 2009 16:54:56 -0000 1.99
+++ modules/system/system.test 3 Jan 2010 23:23:28 -0000
@@ -925,7 +925,7 @@ class PageTitleFiltering extends DrupalW
$langcode = LANGUAGE_NONE;
$edit = array(
"title[$langcode][0][value]" => '!SimpleTest! ' . $title . $this->randomName(20),
- "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200),
+ "body[$langcode][0][value][value]" => '!SimpleTest! test body' . $this->randomName(200),
);
// Create the node with HTML in the title.
$this->drupalPost('node/add/page', $edit, t('Save'));
Index: modules/taxonomy/taxonomy.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v
retrieving revision 1.88
diff -u -p -r1.88 taxonomy.admin.inc
--- modules/taxonomy/taxonomy.admin.inc 3 Jan 2010 00:45:51 -0000 1.88
+++ modules/taxonomy/taxonomy.admin.inc 3 Jan 2010 21:32:48 -0000
@@ -643,13 +643,14 @@ function taxonomy_form_term($form, &$for
'#title' => t('Term name'),
'#default_value' => $edit['name'],
'#maxlength' => 255,
- '#required' => TRUE);
+ '#required' => TRUE,
+ );
$form['description'] = array(
- '#type' => 'textarea',
+ '#type' => 'filter_format',
'#title' => t('Description'),
'#default_value' => $edit['description'],
'#description' => t('A description of the term. To be displayed on taxonomy/term pages and RSS feeds.'),
- '#text_format' => $edit['format'],
+ '#format' => $edit['format'],
);
$form['vocabulary_machine_name'] = array(
@@ -765,10 +766,6 @@ function taxonomy_form_term_submit($form
return;
}
- // Massage #text_format.
- $form_state['values']['format'] = $form_state['values']['description_format'];
- unset($form_state['values']['description_format']);
-
$term = taxonomy_form_term_submit_builder($form, $form_state);
$status = taxonomy_term_save($term);
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.64
diff -u -p -r1.64 taxonomy.test
--- modules/taxonomy/taxonomy.test 10 Dec 2009 15:39:43 -0000 1.64
+++ modules/taxonomy/taxonomy.test 3 Jan 2010 23:29:20 -0000
@@ -380,7 +380,7 @@ class TaxonomyTermTestCase extends Taxon
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
- $edit["body[$langcode][0][value]"] = $this->randomName();
+ $edit["body[$langcode][0][value][value]"] = $this->randomName();
$edit[$this->instance['field_name'] . '[' . $langcode .'][]'] = $term1->tid;
$this->drupalPost('node/add/article', $edit, t('Save'));
@@ -415,7 +415,7 @@ class TaxonomyTermTestCase extends Taxon
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
- $edit["body[$langcode][0][value]"] = $this->randomName();
+ $edit["body[$langcode][0][value][value]"] = $this->randomName();
// Insert the terms in a comma separated list. Vocabulary 1 is a
// free-tagging field created by the default profile.
$edit[$instance['field_name'] . "[$langcode]"] = implode(', ', $terms);
@@ -432,7 +432,7 @@ class TaxonomyTermTestCase extends Taxon
function testTermInterface() {
$edit = array(
'name' => $this->randomName(12),
- 'description' => $this->randomName(100),
+ 'description[value]' => $this->randomName(100),
);
// Explicitly set the parents field to 'root', to ensure that
// taxonomy_form_term_submit() handles the invalid term ID correctly.
@@ -454,11 +454,11 @@ class TaxonomyTermTestCase extends Taxon
$this->clickLink(t('edit'));
$this->assertText($edit['name'], t('The randomly generated term name is present.'));
- $this->assertText($edit['description'], t('The randomly generated term description is present.'));
+ $this->assertText($edit['description[value]'], t('The randomly generated term description is present.'));
$edit = array(
'name' => $this->randomName(14),
- 'description' => $this->randomName(102),
+ 'description[value]' => $this->randomName(102),
);
// Edit the term.
@@ -467,7 +467,7 @@ class TaxonomyTermTestCase extends Taxon
// View the term and check that it is correct.
$this->drupalGet('taxonomy/term/' . $term->tid);
$this->assertText($edit['name'], t('The randomly generated term name is present.'));
- $this->assertText($edit['description'], t('The randomly generated term description is present.'));
+ $this->assertText($edit['description[value]'], t('The randomly generated term description is present.'));
// Check that term feed page is working
$this->drupalGet('taxonomy/term/' . $term->tid . '/feed');
Index: modules/tracker/tracker.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/tracker/tracker.test,v
retrieving revision 1.16
diff -u -p -r1.16 tracker.test
--- modules/tracker/tracker.test 2 Dec 2009 19:26:22 -0000 1.16
+++ modules/tracker/tracker.test 3 Jan 2010 23:34:14 -0000
@@ -74,7 +74,7 @@ class TrackerTest extends DrupalWebTestC
));
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment[value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
@@ -134,7 +134,7 @@ class TrackerTest extends DrupalWebTestC
// Add a comment to the page.
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment[value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); // The new comment is automatically viewed by the current user.
@@ -146,7 +146,7 @@ class TrackerTest extends DrupalWebTestC
// Add another comment as other_user.
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment[value]' => $this->randomName(20),
);
// If the comment is posted in the same second as the last one then Drupal
// can't tell a difference, so wait one second here.
@@ -179,7 +179,7 @@ class TrackerTest extends DrupalWebTestC
$this->drupalLogin($this->other_user);
$comment = array(
'subject' => $this->randomName(),
- 'comment' => $this->randomName(20),
+ 'comment[value]' => $this->randomName(20),
);
$this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save'));
Index: modules/translation/translation.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.test,v
retrieving revision 1.21
diff -u -p -r1.21 translation.test
--- modules/translation/translation.test 2 Dec 2009 19:26:22 -0000 1.21
+++ modules/translation/translation.test 3 Jan 2010 23:35:27 -0000
@@ -61,14 +61,14 @@ class TranslationTestCase extends Drupal
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $this->randomName();
- $edit["body[$langcode][0][value]"] = $this->randomName();
+ $edit["body[$langcode][0][value][value]"] = $this->randomName();
$this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es')));
$duplicate = $this->drupalGetNodeByTitle($edit["title[$langcode][0][value]"]);
$this->assertEqual($duplicate->tnid, 0, t('The node does not have a tnid.'));
// Update original and mark translation as outdated.
$edit = array();
- $edit["body[$node->language][0][value]"] = $this->randomName();
+ $edit["body[$node->language][0][value][value]"] = $this->randomName();
$edit['translation[retranslate]'] = TRUE;
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Page %title has been updated.', array('%title' => $node_title)), t('Original node updated.'));
@@ -79,7 +79,7 @@ class TranslationTestCase extends Drupal
// Update translation and mark as updated.
$edit = array();
- $edit["body[$node_translation->language][0][value]"] = $this->randomName();
+ $edit["body[$node_translation->language][0][value][value]"] = $this->randomName();
$edit['translation[status]'] = FALSE;
$this->drupalPost('node/' . $node_translation->nid . '/edit', $edit, t('Save'));
$this->assertRaw(t('Page %title has been updated.', array('%title' => $node_translation_title)), t('Translated node updated.'));
@@ -130,7 +130,7 @@ class TranslationTestCase extends Drupal
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $title;
- $edit["body[$langcode][0][value]"] = $body;
+ $edit["body[$langcode][0][value][value]"] = $body;
$edit['language'] = $language;
$this->drupalPost('node/add/page', $edit, t('Save'));
$this->assertRaw(t('Page %title has been created.', array('%title' => $title)), t('Page created.'));
@@ -156,7 +156,7 @@ class TranslationTestCase extends Drupal
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = $title;
- $edit["body[$language][0][value]"] = $body;
+ $edit["body[$language][0][value][value]"] = $body;
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('Page %title has been created.', array('%title' => $title)), t('Translation created.'));
Index: modules/trigger/trigger.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v
retrieving revision 1.22
diff -u -p -r1.22 trigger.test
--- modules/trigger/trigger.test 2 Dec 2009 19:26:22 -0000 1.22
+++ modules/trigger/trigger.test 3 Jan 2010 23:36:26 -0000
@@ -39,7 +39,7 @@ class TriggerContentTestCase extends Dru
$edit = array();
$langcode = LANGUAGE_NONE;
$edit["title[$langcode][0][value]"] = '!SimpleTest test node! ' . $this->randomName(10);
- $edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32);
+ $edit["body[$langcode][0][value][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit[$info['property']] = !$info['expected'];
$this->drupalPost('node/add/page', $edit, t('Save'));
// Make sure the text we want appears.
@@ -255,7 +255,7 @@ class TriggerOtherTestCase extends Drupa
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
$edit = array();
$edit['subject'] = $this->randomName(10);
- $edit['comment'] = $this->randomName(10) . ' ' . $this->randomName(10);
+ $edit['comment[value]'] = $this->randomName(10) . ' ' . $this->randomName(10);
$this->drupalGet('comment/reply/' . $node->nid);
$this->drupalPost(NULL, $edit, t('Save'));
Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.72
diff -u -p -r1.72 user.test
--- modules/user/user.test 13 Dec 2009 09:14:21 -0000 1.72
+++ modules/user/user.test 4 Jan 2010 04:05:25 -0000
@@ -539,7 +539,7 @@ class UserCancelTestCase extends DrupalW
// Create comment.
$edit = array(
'subject' => $this->randomString(),
- 'comment' => $this->randomString(),
+ 'comment[value]' => $this->randomString(),
);
$this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
$this->drupalPost(NULL, array(), t('Save'));