Problem/Motivation

With a limited-cardinality Paragraphs field on a content type, I see this 500 error when visiting the /node/add/<type> form:

InvalidArgumentException: Unable to get a value with a non-numeric delta in a list. in Drupal\Core\TypedData\Plugin\DataType\ItemList->get() (line 101 of core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php).

Steps to reproduce

  1. Add a Paragraphs field (or any complex widget that has non-numeric keys) to a content type
  2. Visit the "node add" or "node edit" form for that content type
  3. See the error

Proposed resolution

Filter non-numeric keys from the list, e.g.:

$deltas = array_filter(Element::children($elements), 'is_numeric');

Remaining tasks

  1. Does this deserve test coverage? If so, can you suggest a good test for it?

User interface changes

none

API changes

none

Data model changes

none

Issue fork sam-3268777

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

hawkeye.twolf created an issue. See original summary.

hawkeye.twolf’s picture

Status: Active » Needs review
marcoscano’s picture

Thank you for reporting and for the fix!

I agree that's a bug and we should fix it asap.

In addition, it makes me think if we should be trying to do anything with paragraphs widgets at all. I think we shouldn't, so I opened #3268790: Skip widgets that don't render multiple values as a table so we can approach this in a broader way.

Thanks!

marcoscano’s picture

Assigned: hawkeye.twolf » Unassigned
Status: Needs review » Fixed
Related issues: +#3268790: Skip widgets that don't render multiple values as a table

Status: Fixed » Closed (fixed)

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