Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
If you have a multiple field containing 1 item and if this field is configured to skip the first item, an empty field markup will be output.
Steps to reproduce :
- Create a field field_myfield of type text with multiple values on any content type
- Configure that field display to skip the first item
- Create a content using that field with only one value in field_myfield
- Display that content and look at the HTML output
Current HTML output :
<div class="field field--name-field-myfield field--type-text field--label-hidden">
<div class="field__items"></div>
</div>
Expected HTML output :
No <div class="field field--name-field-myfield field--type-text field--label-hidden">
at all.
Proposed resolution
Hide the entire field if there is no remaining item to show.
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Instructions | ||
Manually test the patch | Novice | Instructions | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions |
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#1 | field_multiple_limit-hide_empty_field-2466649-1.patch | 417 bytes | DuaelFr |
Comments
Comment #1
DuaelFrComment #3
rootworkPatch applies and fixes the bug. Pushed to latest dev. Thanks @DuaelFr for fixing.
Comment #4
rootwork