diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-01 00:00:21 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-01 00:00:21 +0000 |
commit | 8fc5911c36c3671aaaa12dc02506873cec658e00 (patch) | |
tree | 6e516d832464ac1a3d6c7c9e3cd2a5ed1d0c24d5 | |
parent | cfb6452a643276e8ef93b97207172af11cd22fc9 (diff) | |
download | brdo-8fc5911c36c3671aaaa12dc02506873cec658e00.tar.gz brdo-8fc5911c36c3671aaaa12dc02506873cec658e00.tar.bz2 |
#977596 by Stevel, sun, dalin, David_Rothstein: Fixed Text format loses weight and status when saving settings
-rw-r--r-- | modules/filter/filter.admin.inc | 7 | ||||
-rw-r--r-- | modules/filter/filter.module | 2 | ||||
-rw-r--r-- | modules/filter/filter.test | 24 |
3 files changed, 26 insertions, 7 deletions
diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc index 0b053eef7..e20832fa8 100644 --- a/modules/filter/filter.admin.inc +++ b/modules/filter/filter.admin.inc @@ -308,8 +308,11 @@ function filter_admin_format_form_submit($form, &$form_state) { // Remove unnecessary values. form_state_values_clean($form_state); - // Save text format. - $format = (object) $form_state['values']; + // Add the submitted form values to the text format, and save it. + $format = $form['#format']; + foreach ($form_state['values'] as $key => $value) { + $format->$key = $value; + } $status = filter_format_save($format); // Save user permissions. diff --git a/modules/filter/filter.module b/modules/filter/filter.module index 73805a15c..7babfc65f 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -173,6 +173,8 @@ function filter_format_load($format_id) { * to save. If this corresponds to an existing text format, that format * will be updated; otherwise, a new format will be created. * - 'name': The title of the text format. + * - 'status': (optional) An integer indicating whether the text format is + * enabled (1) or not (0). Defaults to 1. * - 'weight': (optional) The weight of the text format, which controls its * placement in text format lists. If omitted, the weight is set to 0. * - 'filters': (optional) An associative, multi-dimensional array of filters diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 524d9de0e..b96c24042 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -185,22 +185,36 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Add text format. $this->drupalGet('admin/config/content/formats'); $this->clickLink('Add text format'); + $format_id = drupal_strtolower($this->randomName()); + $name = $this->randomName(); $edit = array( - 'format' => drupal_strtolower($this->randomName()), - 'name' => $this->randomName(), + 'format' => $format_id, + 'name' => $name, ); $this->drupalPost(NULL, $edit, t('Save configuration')); + // Verify default weight of the text format. + $this->drupalGet('admin/config/content/formats'); + $this->assertFieldByName("formats[$format_id][weight]", 0, t('Text format weight was saved.')); + + // Change the weight of the text format. + $edit = array( + "formats[$format_id][weight]" => 5, + ); + $this->drupalPost('admin/config/content/formats', $edit, t('Save changes')); + $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was saved.')); + // Edit text format. - $format_id = $edit['format']; - $name = $edit['name']; $this->drupalGet('admin/config/content/formats'); $this->assertLinkByHref('admin/config/content/formats/' . $format_id); $this->drupalGet('admin/config/content/formats/' . $format_id); $this->drupalPost(NULL, array(), t('Save configuration')); - // Disable text format. + // Verify that the custom weight of the text format has been retained. $this->drupalGet('admin/config/content/formats'); + $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was retained.')); + + // Disable text format. $this->assertLinkByHref('admin/config/content/formats/' . $format_id . '/disable'); $this->drupalGet('admin/config/content/formats/' . $format_id . '/disable'); $this->drupalPost(NULL, array(), t('Disable')); |