Does not work with layout builder

Created on 26 June 2024, 6 months ago
Updated 30 June 2024, 6 months ago

Problem/Motivation

Throws error when opening layout builder with an entity using condition field

InvalidArgumentException: Invalid values given. Values must be represented as an associative array. in Drupal\Core\TypedData\Plugin\DataType\Map->setValue() (line 82 of /web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php)

InvalidArgumentException: Invalid values given. Values must be represented as an associative array. in Drupal\Core\TypedData\Plugin\DataType\Map->setValue() (line 82 of /web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php)

Backtrace 	
#0 /web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php(89): Drupal\Core\TypedData\Plugin\DataType\Map->setValue()
#1 /web/core/lib/Drupal/Core/Field/FieldItemBase.php(125): Drupal\Core\TypedData\Plugin\DataType\Map->setValue()
#2 /web/modules/contrib/condition_field/src/Plugin/Field/FieldType/ConditionFieldItem.php(160): Drupal\Core\Field\FieldItemBase->setValue()
#3 /web/core/lib/Drupal/Core/TypedData/TypedDataManager.php(216): Drupal\condition_field\Plugin\Field\FieldType\ConditionFieldItem->setValue()

Steps to reproduce

1. Install https://drupal.org/project/eck and https://www.drupal.org/project/condition_field projects on Drupal 10.3 with https://simplytest.me/
2. Add new entity type with Entity Construction Kit (ECK), new bundle and condition field.
3. Go to "Manage display", check "Use Layout Builder" and "Save".
4. Click "Manage layout" and this error happens.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇱🇹Lithuania mindaugasd

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

Comments & Activities

  • Issue created by @mindaugasd
  • Status changed to Postponed: needs info 6 months ago
  • 🇭🇺Hungary nagy.balint

    Hi!

    Can you provide a bit more information on how to reproduce the issue?

    I tried it on my test drupal 11 beta as I had layout builder set up there, and I could not see the issue.

    Maybe it works on nodes, but not on other entity types?

  • 🇱🇹Lithuania mindaugasd

    Hi,

    I just tested with simplytest.me and added steps to issue description.

  • Status changed to Active 6 months ago
  • 🇭🇺Hungary nagy.balint

    Thanks!

    The issue is around this code part:

      /**
       * {@inheritdoc}
       */
      public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
        $values['conditions'] = new ConditionFieldData($field_definition);
        return $values;
      }
    

    Because commenting it out makes it work.

Production build 0.71.5 2024