Add support for delta (multi value fields)

Created on 17 January 2018, almost 7 years ago
Updated 19 February 2023, almost 2 years ago

As there is mentioned in getFieldValue() function:

// @TODO: We should add support for deltas.

Currently the module lacks support for multivalue fields (speaking for 8.x version). Moreover it even breaks your site if you use a multivalued field and set the linked field formatter.

Therefore I will try to provide support for multivalue fields. I already have a basic local version with multivalue field support. I will improve this and test and then provide patch here later. So I am assigning this task to myself now.

πŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany stefan.korn Jossgrund

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States daniel korte Brooklyn, NY

    Re-roll for the 1.4 version

  • πŸ‡ΊπŸ‡¦Ukraine kir.lazur@gmail.com Kiev

    Here is new version of patch with slight change to simplify displaying the value for current field using appropriate token.
    Change highlight:

    // We need special handling for the token destination type.
          if ($destination_type == 'custom') {
            $destination = $manager->replaceToken((is_array($destination) && isset($destination['custom']) ? $destination['custom'] : $destination), $replace_tokens, ['clear' => TRUE,<strong> 'field_name' => $field_name,  'delta' => $delta]</strong>);
    

    It will allows to handle correct delta of current field with multiple values, like entity reference, with example token info like ['tokens']['current-field']['value']

    if ($type == 'current-field' && $token == 'value' && isset($options['delta']) && isset($options['field_name'])) {
    $replacements[$original] = $$data['node']->get($options['field_name'])->get($options['delta'])->target_id;
    
  • πŸ‡ΊπŸ‡¦Ukraine kir.lazur@gmail.com Kiev

    Updated version of patch

  • πŸ‡ΊπŸ‡¦Ukraine kir.lazur@gmail.com Kiev

    here the latest version including tokens as well

  • πŸ‡ΊπŸ‡¦Ukraine kir.lazur@gmail.com Kiev

    updated version with needs-data for token

Production build 0.71.5 2024