Components with no properties break config form

Created on 4 June 2024, 21 days ago

Problem/Motivation

If a component without props is selected for entity view display, the display config form breaks with

TypeError – Adaptor SchemaForms\Drupal\FormGeneratorDrupal received invalid input data: [].

Steps to reproduce

  1. Activate „Render using a component“ in the display config form
  2. Select a component that has no props with YML according to https://www.drupal.org/docs/develop/theming-drupal/using-single-director...
  3. Save
  4. Observe the error message as noted above

Proposed resolution

Observations:

  • The solution proposed in 🐛 Components with no properties break config form Fixed is already applied, but doesn't work. The schema validator returns „Array value found, but an object is required“
  • Forcing the schema validator to use Constraint::CHECK_MODE_TYPE_CAST removes the validator type error, but still fails, because JsonSchemaFormValidator::isValid also requires (bool) $data->properties to be true, which is not the case for empty arrays.

So either

  1. Use Constraint::CHECK_MODE_TYPE_CAST and remove the (bool) $data->properties check
  2. Somehow make sure that empty YAML objects get transformed into empty PHP objects instead of empty arrays

No clue if the second option is feasible.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany Feuerwagen Bonn 🇩🇪🇪🇺

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

Comments & Activities

Production build 0.69.0 2024