[2.0.0-beta1] Add AtributesPropType::normalize()

Created on 18 July 2024, about 2 months ago
Updated 2 August 2024, about 1 month ago

Problem/Motivation

In AttributesWidget::getPropValue() we are returning a PHP array instead of an attribute object to not raise validation error from SDC render element, because AtributesPropType schema is:

[
    'type' => 'object',
    'patternProperties' => [
      '.+' => [
        'anyOf' => [
          ['type' => ['string', 'number']],
          [
            'type' => 'array',
            'items' => [
              'anyOf' => [
              ['type' => 'number'],
              ['type' => 'string'],
              ],
            ],
          ],
        ],
      ],
    ],
  ]

So, we ask people to add create_attribute() inside the twig template. I beleive it is cleaner like that, and it will be come a good practice in the future ( HTML attributes as Twig mappings instead of PHP objects Active ) but it is currently a regression compared to UI Patterns 1.x which was doing that in AttributesSettingType::preprocess()

Proposed resolution

Is it possible to do this transformation from array to Attribuet object in AtributesPropType::normalize() (which was introduced later in development) instead ?

Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

🇫🇷France pdureau Paris

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024