Nested multivalue field's button add two fields intead of one.

Created on 18 October 2023, about 1 year ago
Updated 30 October 2023, about 1 year ago

Problem/Motivation

If you use a nested multivalue field, and you click on add another item of the nested field, it adds two fields instead of one.

Steps to reproduce

Add a nested multivalue field and click on add another item of the nested field. Here is the example code.

$form['contact_information'] = [
      '#type' => 'multivalue',
      '#title' => $this->t('Contact information),
      '#cardinality' => MultiValue::CARDINALITY_UNLIMITED,
      '#default_value' => $this->config->get('contact_information') ?? [],
      'mail' => [
        '#type' => 'multivalue',
        '#title' => $this->t('E-Mail'),
        '#cardinality' => MultiValue::CARDINALITY_UNLIMITED,
        'email_address' => [
          '#type' => 'email',
          '#title' => $this->t('E-mail address),
        ],
      ],
      'website' => [
        '#type' => 'url',
        '#title' => $this->t('Website'),
      ],
    ];

Here if you click on the Add another item of the mail field, it adds two more mail fields. While it should add one mail field only.

Proposed resolution

The nested multivalue field should work fine and it should add a single field on clicking the Add another item

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇵🇰Pakistan hmdnawaz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024