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.

Files: 
CommentFileSizeAuthor
#1 enTIChQ.png65.86 KBalimac

Comments

alimac’s picture

Issue summary: View changes
FileSize
65.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.