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

Comments

hmdnawaz created an issue. See original summary.

hmdnawaz’s picture

Issue summary: View changes
hmdnawaz’s picture

Any update on this issue?