This project is not covered by Drupal’s security advisory policy.

Multivaluefield

Multivaluefield (Multiple values field) is a drupal field plugin, allow to add multiple values on one field.

Drupal 9 ready.
Compatible with feeds.

Examples

Add / Create node programmatically with a "Multivaluefield" field

Example 1.

\Drupal\node\Entity\Node::create(array(
  'type' => 'page',
  'title' => 'Mvf testing page',
  'status' => 1,
  'field_mvf' => [
    'index' => 'Test index 1',
    '0' => "Fields Value 1",
    '1' => "Fields Value 2",
  ],
))->save();

Example 2.

(With $nid = Previously created node ID)

$entity = \Drupal\node\Entity\Node::load($nid);
$values = [
  'index' => 'Test index 2',
  '0' => "Fields Value 3",
  '1' => "Fields Value 4",
];
$entity->set('field_mvf', [$values, $values]);
$entity->save();

Similar Projects

- Paragraphs (https://www.drupal.org/project/paragraphs)
- Field collection (https://www.drupal.org/project/field_collection)

Different from the Paragraphs and Field collection

Lite-weight
Store all values in the same field (JSON)
Field configuration is stored on field storage configuration.
No need to create separate configurations
....

Project information

Releases