summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-24 04:18:10 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-10-24 04:18:10 +0000
commit2079d300b43e597d5f532caa4deef1111856a31d (patch)
tree4d065ccf7bd02b3aff86a879960c4c58d7af0868
parente8716ebf2572befbae7d73639e1c769f9b709b9b (diff)
downloadbrdo-2079d300b43e597d5f532caa4deef1111856a31d.tar.gz
brdo-2079d300b43e597d5f532caa4deef1111856a31d.tar.bz2
#617596 by ygerasimov, furamag: Fixed Non-empty Summary and empty Body both become empty when saved.
-rw-r--r--modules/field/modules/text/text.js2
-rw-r--r--modules/field/modules/text/text.module7
-rw-r--r--modules/field/modules/text/text.test23
3 files changed, 30 insertions, 2 deletions
diff --git a/modules/field/modules/text/text.js b/modules/field/modules/text/text.js
index 877132e40..f96075ae5 100644
--- a/modules/field/modules/text/text.js
+++ b/modules/field/modules/text/text.js
@@ -38,7 +38,7 @@ Drupal.behaviors.textSummary = {
).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
- if ($(this).val() == '') {
+ if ($(this).find('.text-summary').val() == '') {
$link.click();
}
return;
diff --git a/modules/field/modules/text/text.module b/modules/field/modules/text/text.module
index 59425cb82..c4739a4d1 100644
--- a/modules/field/modules/text/text.module
+++ b/modules/field/modules/text/text.module
@@ -171,7 +171,12 @@ function text_field_load($entity_type, $entities, $field, $instances, $langcode,
*/
function text_field_is_empty($item, $field) {
if (empty($item['value']) && (string) $item['value'] !== '0') {
- return TRUE;
+ if ($field['type'] == 'text_with_summary') {
+ return (empty($item['summary']) && (string)$item['summary'] !== '0');
+ }
+ else {
+ return TRUE;
+ }
}
return FALSE;
}
diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test
index 5f4b0c19d..903cc8ea5 100644
--- a/modules/field/modules/text/text.test
+++ b/modules/field/modules/text/text.test
@@ -242,6 +242,11 @@ class TextSummaryTestCase extends DrupalWebTestCase {
);
}
+ function setUp() {
+ parent::setUp();
+ $this->article_creator = $this->drupalCreateUser(array('create article content', 'edit own article content'));
+ }
+
/**
* Tests an edge case where the first sentence is a question and
* subsequent sentences are not. This edge case is documented at
@@ -376,6 +381,24 @@ class TextSummaryTestCase extends DrupalWebTestCase {
$summary = text_summary($text, $format, $size);
$this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected)));
}
+
+ /**
+ * Test sending only summary.
+ */
+ function testOnlyTextSummary() {
+ // Login as article creator.
+ $this->drupalLogin($this->article_creator);
+ // Create article with summary but empty body.
+ $summary = $this->randomName();
+ $edit = array(
+ "title" => $this->randomName(),
+ "body[und][0][summary]" => $summary,
+ );
+ $this->drupalPost('node/add/article', $edit, t('Save'));
+ $node = $this->drupalGetNodeByTitle($edit['title']);
+
+ $this->assertIdentical($node->body['und'][0]['summary'], $summary, t('Article with with summary and no body has been submitted.'));
+ }
}
class TextTranslationTestCase extends DrupalWebTestCase {