
Follow-up to #314385: Make position of #description configurable via the API
Problem/Motivation
The description for multiple value form widget appears after the field table. It should be possible to configure the description to appear above the field table.
There is a Label Help module for 7.x that does this -- https://www.drupal.org/project/label_help -- it should probably be incorporated into core.
Steps to reproduce
Create multi value form widget with a description.
Screenshot from https://www.drupal.org/node/314385#comment-7254776
Proposed resolution
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Update the issue summary | Instructions | done | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
User interface changes
No changes. (but adds a way for things to change.)
API changes
Change to form api.
Comment | File | Size | Author |
---|---|---|---|
#1 | enTIChQ.png | 65.86 KB | alimac |
Comments
Comment #1
alimac CreditAttribution: alimac commentedComment #2
alimac CreditAttribution: alimac commentedComment #3
kaareI just wanted to give you a heads up about a new project that solves this for D7: Form element layout. I would love to see a similar solution for D8. Unfortunately my work requires me to be in D7 land for quite some while, so I have no time to help in this issue.
Comment #4
kaareOh and yeah. Label help doesn't solve this. Quoting from its project page:
…
Comment #5
kaareDunno if it is related, but one of the biggest problem I had with Form element layout fields was that I had no idea how field widgets would structure their forms. So where the
#description
finally ended up (beeing rendered) wasn't possible to figure out programmatically, afaik. Maybe its easier in D8 now that field widgets have schema.Comment #6
penyaskitoIn multiple fields, the name of the field is output in the
<thead>
of a table. How could we inject the description if we want to show it before the actual fields, but after the title?Comment #7
alimac CreditAttribution: alimac commentedHm. What about using a
<caption>
, which could then be positioned below or above the table using CSS? It won't put it in between thead and table contents, but given that multiple value form widget uses a table, it's different enough from single value form fields that it might warrant using a caption for description/help text.Comment #8
penyaskito@alimac: The caption is shown before the table (and the h4), so I'm not sure if that is a potential solution.
Comment #9
kaareI just opened #2371945: Move multivalue field's label out of rendered table to a separate <label> to provide HTML consistency that hopefully will move the label outside the table. Otherwise the help text will have to be rendered as a stand-alone table row after
<thead>
and before the input elements. But that again opens the question if it's the right thing to render the help text as a table row at the end of the table also if#description_display
is set toafter
for multi value fields. The fact that the field's label is a part of the table is a really bad thing and IMHO borderline a bug.Getting momentum on the above issue will help this issue a lot.
Comment #10
mgiffordThere's no patch to work on.
Comment #11
mgiffordLet's bump this to 8.1.
Comment #12
mgiffordComment #14
imiksuCleaning up drupalcampfi tags.
Comment #19
jwilson3Since Label Help was mentioned in the issue description above, I thought I'd throw out that a Drupal 8 port has been created and along with the patch on #2948501: Improve Drupal 8 field compatibility, it is working nicely for a large number of field types, including multi-cardinality fields like those depicted in the screenshot of this issue's description above.
The Label Help module's D8 version tries to add the description to the #label_suffix, but since field-multiple-tables in Drupal 8 do not support #label_suffix, the patch on #2948501 simply appends the description to the #title so that it appears inside the
<h4 class="label>
.While I'm not trying to change the purpose of this issue, it would be super slick if #label_suffix was just made to work with multi-cardinality fields.
Comment #20
jwilson3Comment #23
mlncn CreditAttribution: mlncn at Agaric for Drutopia, Find It Cambridge, Cambridge, Massachusetts Family Policy Council commentedComment #24
mlncn CreditAttribution: mlncn at Agaric for Drutopia, Find It Cambridge, Cambridge, Massachusetts Family Policy Council commented