Overview
I created a yml config that requires content_attributes from twig. I added it as part of my component.yml. As I understand that any properties will be shown in the UI so how do I hide this?
Here is the an example config I use:
$schema: https://git.drupalcode.org/project/drupal/-/raw/10.1.x/core/modules/sdc/src/metadata.schema.json
name: Card Icon
status: stable
props:
type: object
properties:
content_attributes:
type: string
title: 'Content attributes'
description: 'Same as attributes, except applied to the main content tag that appears in the template.'
title:
type: string
title: 'Title'
description: 'Main title'
body:
type: string
title: 'Body'
description: 'Main content text'
more_content:
type: string
title: More content
description: 'Additional content'
required:
- content_attributes
Proposed resolution
I would like to be able to hide some settings in the UI.
User interface changes
Comments
Comment #2
lauriiiComment #3
nx2611 commentedComment #4
wim leersThe
typeis wrong:should be
If you do that, it'll be ignored automatically :) 👍
Interested in knowing why/how? → See this bit in
\Drupal\experience_builder\PropShape\PropShape::getComponentPropsForMetadata():Comment #5
wim leersAh, lol, I misread my own code 🙈
→ what I wrote is not true. It should just check the type?
Comment #7
wim leersMR with test coverage up. 👍
But … does this even work? Doesn't
\Drupal\Core\Template\ComponentsTwigExtension::mergeAdditionalRenderContext()only support a singleattributesprop? 😅So that's definitely an upstream bug in SDC.
Comment #8
penyaskitoAssigning for the feedback you asked and removing tag. Not saying that you are the one who should fix the tests 😁
Comment #9
wim leers🏓
Comment #10
wim leersPer #3513406-8: ValueError: "Drupal\Core\Template\Attribute" is not a valid backing value for enum, this affects the quite popular https://www.drupal.org/project/radix theme significantly.
Basically this just needs to be generalized:
\Drupal\experience_builder\ComponentMetadataRequirementsChecker::check()… which is the direction @penyaskito's in-progress MR already is taking 👍 Let's revive & land it!
Comment #14
wim leersMarked #3513406 as a duplicate per #3513406-13: ValueError: "Drupal\Core\Template\Attribute" is not a valid backing value for enum. Crediting the contributors there that helped get clarity there, which allowed marking it as a duplicate 😊
Comment #15
penyaskitoMentioned today, while we are here let's ensure we have a plan (fix here or follow-up) for Attributes prop marked as required works, even if that doesn't make any sense.
Comment #16
penyaskitoComment #17
penyaskitoComment #18
wim leers👆 This is not yet addressed, but the MR is ready, so tagging .
Also linking the core issues that @penyaskito found in his research at https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...
Comment #19
wim leersLGTM — only needs addressing of @larowlan's edge case, and just have 2 minor questions.
Comment #20
penyaskitoHandled feedback. Created follow-up`#3537610: Handle required `type: Drupal\Core\Template\Attribute`s props in SDCs
Comment #21
wim leersThanks!
Comment #23
wim leersThanks!