Problem/Motivation
Sometimes you want to force content-editors to provide a summary. Use case would include
- You're showing it in a teaser display mode
- You're using it for the metatag description
- You're using it for search results
The summary input is easy to miss, but is really useful as it avoids needing a second text field for teaser text.
Proposed resolution
Setup options for the "Text area with a summary" widget to allow for the Summary field to be "Shown by default" (instead of collapsed with js) and a field level setting to make the summary value "Required".
Remaining tasks
- manual testing (See contributor task doc for instructions on manual testing: http://drupal.org/node/1489010) Especially see #42 on for what combinations to test.
- Reviews
User interface changes
New checkbox on text with summary widget and text with summary field.



API changes
No api changes.
Related Issues
| Comment | File | Size | Author |
|---|---|---|---|
| #115 | 1704864-summary-required-115.patch | 21.76 KB | larowlan |
Comments
Comment #1
nick_schuch commentedAttached an implementation of this.
Comment #3
nick_schuch commented#1: 1704864-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #5
nick_schuch commented#1: 1704864-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #7
nick_schuch commentedSecond attempt.
Comment #8
tim-e commentedTested and reviewed, working perfectly.
Comment #9
catchI'm not sure why this is a useful feature, or what exactly it'll look like when used. Adding 'needs usability review' and 'needs screenshots' tags.
Comment #10
tim.plunkettFixing tag
Comment #11
Bojhan commentedCan't review. Needs screen.
Comment #12
bulldozer2003I was just looking for this in 7. Going to backport it as a module for my own use.
Comment #13
nick_schuch commentedI have rerolled that patch as the text module has been taken out of field module.
Comment #14
nick_schuch commentedCatch, I have attached a screenshot of what this looks like when the following settings are selected:
- Show Summary
- Mark Summary as required
Comment #15
larowlanHere's the screenshot from #14

Having this feature means instead of adding two fields to a content type (eg a body and a teaser), you can just force the body field to display the summary field and make it required (editors regularly miss the 'show summary' link). Then you can use that as the teaser.
I think its a worthy feature, but it need tests.
Comment #16
larowlanAlso the description 'leave blank' needs to be changed when the required flag is set.
Comment #17
larowlanAdding back ux tag
Comment #18
Bojhan commentedLooks fine.
Comment #19
nick_schuch commentedWritten tests to check for required summary field. Also actioned #16 request of "Also the description 'leave blank' needs to be changed when the required flag is set.".
Comment #20
larowlanThis looks great, and now with tests.
Down to minor nitpicks now.
This can be simplified to
$required = (empty($form['#type']) && !empty($this->instance['settings']['required_summary']));Do we need a followup to make this use libraries instead since #1737148: Explicitly declare all JS dependencies, don't use drupal_add_js, will ask nod_
I don't think this is used?
Nitpick but the assertion message is confusing. How about 'Unable to save article without a required summary' or something else, not fussy.
Again, this can be simplified to !empty($settings['show_summary'])
Text here is wrong. Suggest 'Summary field is always visible' or similar.
This can be simplified too
Mark not marks
Comment #21
nick_schuch commentedThanks larowlan!
Have made the changes and provided an interdiff.
Comment #22
larowlanAssuming bot comes back green, this looks good to go
Comment #23
tim.plunkettThis will cause drupal_process_attached() to be called even when it doesn't need to be.
Instead it should be something like this, after the initial element is made
Comment #24
nick_schuch commentedThanks tim.plunkett
I have attached the update and with its respective interdiff. I have also setup a follow up for text module to use hook_library_info for the loading of text.js here #1888744: text.module missing text_library_info() - does not explicitly declare js dependencies.
Comment #25
tim.plunkett['js'] = array(vs['js'][]would be a problem if this wasn't for an element we just finished making, so this is good. Thanks @nick_schuch!Setting back to RTBC per #22.
Comment #26
nick_schuch commented#1888744: text.module missing text_library_info() - does not explicitly declare js dependencies has been committed so I have rerolled our current patch.
Comment #27
webchickSorry; since that one was a straight-up bug fix and this one is a feature and blocked on thresholds, it seemed more prudent to commit it first.
Comment #28
nick_schuch commentedHi webchick, not a problem. Thanks for committing my other patch. Just found an issue in my current reroll :)
Have fixed in this patch.
Comment #29
larowlanCan we get an interdiff if possible?
Comment #30
nick_schuch commentedNo probs larowlan. Here's the interdiff for #28 after rerolling against latest 8.x branch.
Comment #31
larowlanAnd we're back
Comment #32
effulgentsia commentedComment #33
webchickThere've been lots of changes to this part of the code recently, so going for another testbot run.
In case it doesn't finish before I go to bed, tagging as something that was RTBC in time for feature freeze.
Comment #34
webchick#28: 1704864-28-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #36
nick_schuch commentedLooks like it was just a case of permissions moving on.
Comment #37
larowlanThis is good to go again.
Also helps with proposed solution from @yched at #626546-62: The body field on the Basic Page content type should not allow a summary to be input
Comment #38
webchickTwo small things, then this looks good to go:
Not sure "Show summary" is obvious enough that that's what that means? How about "Always show summary" and ditch the description?
:)
Don't need a description that says exactly what the field title is. :) Also we could shorten this to just "Require summary"
Comment #39
nick_schuch commentedHere are the recommended fixed as identified by webchick. Thanks webchick!
Comment #40
larowlanFixed as requested
Comment #41
xjm#39: 1704864-39-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #42
xjmI've discovered a bug unfortunately. :(
So, we need to fix the JS to show the field when that happens.
Comment #43
xjmAlso, it would be good to add some screenshots: the field instance settings with the patch applied, the summary failing validation, the "always show" behavior, etc.
Comment #44
alexverb commentedThis might have do do something with the WYSIWYG editor on top. There's a similar issue here: http://drupal.org/node/1338956 But it has to be fixed upstream by the editors. I tried raising the issue at ckeditor, but my voice doesn't carry enough weight. That's why I provided a workaround.
If it's only the summary field without the editor you might just want to add a "novalidate" property to the textarea input so HTML5 validation doesn't catch it. I'm not a big fan of browsers HTML5 validation. In fact I think Drupal should provide a checkbox to disable it entirely. Unless the browser also wants to take over the theming for us :)
Comment #45
xjmI actually think that when the summary is required, the option to hide/show should go away and the field should always be shown.
Comment #46
nick_schuch commentedThanks xjm!
Turn's out the summary field being hidden via the javascript also hides the message to state that the summary field is required (when not filled out). I have implemented the suggested option provided by xjm in #45 to resolve.
See the following screenshots:
Comment #47
nick_schuch commentedHere is the patch (woops forgot to add in last comment) and interdiff.
Comment #48
nick_schuch commentedSlight description change.
Comment #49
nick_schuch commentedAlso adding back in tags removed in #44.
Comment #49.0
yesct commentedused issue summary template and added links for new contributors to do tasks
Comment #50
ariley4 commentedIm going to perform the screenshots for this issue.
Comment #51
ariley4 commentedI tried to use the simplytest.me with Dreditor and there was an error. Then I tried it without and still received the same error. I dont know what to do.
Comment #52
nick_schuch commented#48: 1704864-48-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #54
nick_schuch commented#48: 1704864-48-required-and-show-by-default-for-text-summary.patch queued for re-testing.
Comment #56
andymartha commentedGreat job by everyone working on this issue! Here are some screenshots of the issue in question after applying patch 1704864-47-required-and-show-by-default-for-text-summary.patch by nick_schuch in #47
I confirm that the patch hides the "always show summary" option when "require summary" is checked per #46
1) Drupal 8 without the patch
2) Drupal 8 with the patch
3) clicking save and publish does not visibly do anything because the html5 browser error message happens in the hidden summary area
4) older, non-html5 browsers get this message from Drupal with a blank, required summary
Comment #57
nick_schuch commentedThanks andymartha! I'll reroll today to make sure the bot comes back green so we can get it RTBC again!
Comment #58
nick_schuch commentedPatch to make the tests go green.
Comment #59
star-szrManually tested and screenshots added in #56, removing tags.
Comment #60
Stalski commentedRerolled the patch to make it green again.
I also removed the test for it. It seems a couple of tests (webcasetests) have been removed in favour of unit tests. Do we need this small test for the required fields, any idea's?
Comment #61
nick_schuch commentedThanks for the reroll Stalski.
Can you please provide a interdiff so we can see the changes made between patches?
We will need test coverage. So looks like we will need to do a unit test. :)
Comment #63
Stalski commentedOk, agreed.
I'll try to cover that today.
Comment #64
Stalski commentedI did not add an interdiff since it wouldn't add any value. Lots of files were moved etc ... . The old patch does not apply in the new core by miles.
So the unit test is extended so it can check the required summary.
Comment #66
Stalski commentedTook the diff in the wrong order. Correct patch
Comment #67
nils.destoop commentedTested this patch, but found one issue.
When the summary is marked as required, and you edit the field again. You are required to enter a summary on the edit field screen.
Comment #68
Stalski commentedThx for the review.
I had that error as well and it went away. The problem is that the extra added element does not go through the widget flow as the field itself does.
There is a quick and easy fix for it to check if we are rendering the default widget or the normal one.
Patch coming up.
Comment #69
Stalski commentedThe patch and interdiff.
Comment #70
Stalski commentedSorry, had the patch the other way around. New patch / interdiff.
Comment #72
nils.destoop commentedComment #73
nils.destoop commentedComment #74
nils.destoop commented#70: text_required_summary.1704864-69.patch queued for re-testing.
Comment #76
Stalski commented#70: text_required_summary.1704864-69.patch queued for re-testing.
With the tests applied, it's all green. Don't know why this is crashing on a fatal error atm.
Comment #78
Stalski commentedRerolled it against latest dev.
Comment #80
Stalski commentedRerolled again.
Comment #82
Stalski commentedagain
Comment #83.0
(not verified) commentedfix copy and paste error
Comment #84
sunThis comes very late in the game, but does not appear to have been questioned yet:
Why do we want to enhance the compound textarea+summary field in these substantial ways, if all of your goals are covered by adding a separate summary text field?
The moment you make the summary required, we're really talking about a separate field → proper validation, error messaging, separate values, widget/formatter control, integrations, etc.pp.
It's not clear why we'd want to shoehorn all of that into a compound textarea+summary field?
Thoughts?
Comment #85
Stalski commentedAgreed actually, so would we need a separate compound then?
Comment #86
luksakIn the meantime there is a contrib module to accomplish this: Summary settings
I had this use case once and agree that this would be useful. Should we leave it contrib or put that in core?
Comment #87
mgiffordThere has been no new work on this issue in quite some time. So I'm assuming the person assigned is no longer being actively pursuing it. Sincere apologies if this is wrong.
Comment #90
generalredneck> Why do we want to enhance the compound textarea+summary field in these substantial ways, if all of your goals are covered by adding a separate summary text field?
I would venture to guess that it's a usability answer here. Taking the optional "Required" setting out of this, making it visible by default would help encourage (or even show users they CAN) add a summary for the teaser. By default the verbiage kinda gets overlooked.
For the required. You are correct. At that point, yeah we are talking about a full on another field. What it means for site builders is they can add in this without having to go reconfigure all the displays and/or templates that currently say "Display the body field"
Not saying that these are compelling reasons. Just thought I would add to this old discussion to see if it spawns any progress and/or decisions other than "Needs Work"
Comment #93
rcodina1) For Drupal 7: https://www.drupal.org/project/text_summary_options
2) Any update on this issue for Drupal 8?
Comment #94
rcodinaI've just done a port to D8 for text_summary_options module. More details here #2923443: Offering to maintain Summary Options (Drupal 8 version)
Comment #97
larowlanComment #98
kostyashupenkoComment #100
larowlanComment #103
larowlanWorked on this with @irawan and @ling-drupal
Comment #105
larowlanComment #107
larowlanComment #109
larowlanComment #110
larowlanOK, self review - I know I RTBC'd this a couple of times in the last 6 years (gasp) but things have changed since then - so I think there are two more changes required.
This belongs on the widget in my opinion
We also need a validation constraint for this, for API clients
Comment #111
larowlanWe also need an update path now too, to update the configuration
Comment #112
larowlanAdds update path
Adds test coverage for update path
Adds validation constraint for API clients with the required summary field
Adds test coverage for validation constraint
Moves the show summary from the field settings to the widget settings, as its more appropriate there (its not a data option, its a display option).
Comment #113
larowlanComment #115
larowlanFixed deprecation error from test and phpcs issue
Comment #116
jibranThe patch looks good to me nothing to nit pick. Needs screenshot about new settings in UI and error. Needs change record with screenshot and it might need a usablity review for the new string and settings added here.
Conventionally, we perform on config change per hook so that other module can run their changes in between if they want to but in this case, I don't this is necessary.
Comment #117
larowlanAdded screenshots and a change record
Comment #118
jibranThanks, this looks good now.
Comment #120
larowlanrandom fail
Comment #122
yogeshmpawarSetting back to RTBC!
This is not happening anymore.
Comment #123
catchTagging for usability and product manager review since the last time webchick looked at this was six (!) years ago.
Comment #124
webchickWow, this is a blast from the past. :)
The use case in the issue summary makes sense to me, and looks like @Bojhan signed off UX-wise in #11 7(!) years ago.
I read through the whole issue, in part to figure out why it took this long to resolve, and it seems like the main objection was @sun in #84, essentially asking what the value of these options are over having two text fields.
I think the value is that, for better or for worse, Drupal has shipped with this Body + Summary field concept since ages ago (Drupal 5?), and there are various parts of the system that make assumptions about that summary field / teaser view (e.g. the default front page view). Adding these settings here mean not having to manually go find all of those places and manually undo their assumptions, to instead utilize a custom "Teaser" field. And in the event that something like #1378350: Clean up the "Long text and summary" field ever happens, it seems like these settings help bring the field further inline with others, and would help make that migration easier.
So with that....
Committed and pushed to 8.8.x! TENACITY OF THE DECADE AWARD, FOLKS!! :D However, I am not planning to backport this to 8.7.x, since it's a "nice to have" vs. a bug fix.
Comment #126
larowlanpublished change record