Problem/Motivation

I am finding that the last field item of a multivalue field is not rendering when the "nomarkup" setting is turned on for the field.

I am using the module with a multivalue paragraph/entity reference revisions field but I think the issue will happen with other multivalue field types.

Steps to reproduce

  • Add a multi-value field to a node.
  • Enable the "nomarkup" field formatter setting for the field.
  • Create a new node and add 2 or more field items.
  • View page, should not see the last item rendering.
  • Turn off the "nomarkup" field formatter setting for the field.
  • View the page again, should see all field items.

Proposed resolution

Looking at the field--nomarkup.html.twig template the issue seems to be line 8:

{{- items[items|length].content -}}

I think it needs to be:

{{- items[items|length - 1].content -}}

to access the last element.

Remaining tasks

  1. Confirm bug.
  2. Create patch.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork nomarkup-3299838

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

PCate created an issue. See original summary.

e0ipso’s picture

Status: Active » Fixed

Fantastic catch!!

  • e0ipso committed b279cfe on 1.x authored by PCate
    Issue #3299838 by PCate: Last item of multivalue fields are not renders
    
e0ipso’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.