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

Contributor tasks needed
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.

CommentFileSizeAuthor
#1 enTIChQ.png65.86 KBalimac

Comments

alimac’s picture

Issue summary: View changes
StatusFileSize
new65.86 KB
alimac’s picture

Title: Make position of #description configurable via the API » Make position of #description configurable via the API for form field widgets
kaare’s picture

I 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.

kaare’s picture

Oh and yeah. Label help doesn't solve this. Quoting from its project page:

This module attempts to provide a more comprehensive, flexible and simpler-to-implement solution: a second help field that will appear directly below the form element's label.

This module does not alter the positioning of the standard "description" field, so it is actually possible to have two separate pieces of "help" text for each form field -- one that appears directly below the label, and another that appears below the input form as it does now. (In practice, of course, most form fields will not need both.)

kaare’s picture

Dunno 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.

penyaskito’s picture

In 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?

alimac’s picture

Hm. 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.

penyaskito’s picture

@alimac: The caption is shown before the table (and the h4), so I'm not sure if that is a potential solution.

<table id="body-values" class="field-multiple-table responsive-enabled tabledrag-processed tableresponsive-processed">
      <caption>Hello</caption>
      <thead>
      <tr>
                  <th colspan="2" class="field-label"><h4 class="label">Body</h4></th>
                  <th class="tabledrag-hide" style="display: none;">Order</th>
              </tr>
    </thead>
      <tbody>
kaare’s picture

I 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 to after 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.

mgifford’s picture

Status: Needs work » Active

There's no patch to work on.

mgifford’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Active » Postponed

Let's bump this to 8.1.

mgifford’s picture

Status: Postponed » Active

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

imiksu’s picture

Issue tags: -drupalcampfi

Cleaning up drupalcampfi tags.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jwilson3’s picture

Since 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.

jwilson3’s picture

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.