Problem/Motivation

There are components that have nested properties like this:

...
props:
  type: object
  properties:
    links:
      title: Links
      type: array
      items:
        type: object
        properties:
          url:
            title: Url
            type: ["string"]
          title:
            title: Text
            type: ["string"]
...

Currently, to fill these properties there appears a textfield/textarea. It would be nice to have a field for each property.

Proposed resolution

Modify sdc_styleguide_array plugin to support nested properties.

CommentFileSizeAuthor
#9 Screen Shot 2026-08-12 at 10.43.07.png185.79 KBmortona2k
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

omarlopesino created an issue. See original summary.

omarlopesino’s picture

Status: Active » Needs work

Working on it, see the attached MR. I will go back on this tomorrow to review if it is possible to add a different form element type for each property type.

alemadlei’s picture

Question,

Was this stated somewhere on the original SDC definition?

I mean, I think it is indeed possible, but working on SDC so far, when this happens I prefer to use slots to have components in components.

alejandro cabarcos’s picture

Hello Alejandro,

First of all thanks for your work on this module, we already implemented it on several projects and planning to make it a must-have on our stack.

Im thinking about a component with multiple links, where you want to trigger SDC prop validation to make it easier for content editors.

props:
  type: object
  properties:
    links:
      title: Links
      type: array
      items:
        type: object
        properties:
          url:
            title: Url
            type: string
            format: uri
          title:
            title: Text
            type: string
          classes:
            title: Text
            type: string
            enum:
                - btn-primary
                - btn-secondary
                - btn-link

According to https://www.drupal.org/docs/develop/theming-drupal/using-single-director... its allowed a prop of type: array

omarlopesino’s picture

Status: Needs work » Needs review

Moving to needs review as it is complete and tested internally. Please review, thanks!

mortona2k’s picture

Status: Needs review » Needs work

MR is not working for an array of objects. I see a multivalue text field, and it's disabled.

mortona2k’s picture

Status: Needs work » Needs review
StatusFileSize
new185.79 KB

I was able to get it working with claude:

Only local images are allowed.

Added as a separate MR for further review.

For this case, I'm looking at the menu-tree component from the Menu Tree module.