diff options
-rw-r--r-- | modules/field/modules/text/text.js | 2 | ||||
-rw-r--r-- | modules/field/modules/text/text.module | 7 | ||||
-rw-r--r-- | modules/field/modules/text/text.test | 23 |
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 { |