Closed (fixed)
Project:
UI Patterns (SDC in Drupal UI)
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
14 Jul 2024 at 10:56 UTC
Updated:
22 Jul 2025 at 11:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
christian.wiedemann commentedComment #4
christian.wiedemann commentedIt's not so easy to access the entity inside layout forms. This should work now in every case.
Comment #5
sea2709 commentedI checked out your fix and did some testing. I created a SDC component "Call To Action", and I had a paragraph type "Call To Action". I used Layout Builder to configure the paragraph display with a SDC component "Call To Action" section. I selected Entity as "Paragraph", it's interesting that if I use "Token" as a source for each prop, it works, but if the source is "Data from a field", it doesn't work.
I'm not sure if it's in the scope of this issue or it belongs to another issue!
Comment #6
just_like_good_vibesHello sea2709, thank you for your feedback.
About your test, is your Call to Action Body a prop or a slot?
when you say, it doesn't work, did you mean that when you select the source "Data from a field", and then you select a specific field,
then, no source is showing?
if no source is showing, that could mean ui_patterns couldn't find a compatible source for the field you have selected and the prop (or slot) you are trying to set a value for.
There may be a bug indeed, there may be a small context requirement missing. If you were trying to extract a field property from the source "data from a field", the field property can only show in certain conditions (at least your field needs to be a single value field) and the current implementation seems to have a little bug (in your case, if i am not wrong "field_granularity:item" should have been in the context_requirements context)
Comment #7
just_like_good_vibesi just added a very small fix in the MR of Christian to cope with the case you provided. thank you :)
Comment #8
pdureau commentedHi Christian, do you need to do something else here?
Comment #9
sea2709 commentedThanks for working on this.
The fix worked! I was able to use layout builder to configure a paragraph display. In the section configuration, I selected a SDC component, and select "Paragraph" as an entity, and then selected the source as "Data from a field", and configured the appropriate fields and field properties. All of fields in my component are props.
Comment #10
just_like_good_vibesgood news for the fix, many thanks for the rapid feedback :)
Comment #11
pdureau commentedMikael, can you have a look?
Comment #12
pdureau commentedComment #13
christian.wiedemann commentedI removed token context mapping in this context. Sources should not have any kind of context mapping because we have DerivableContext handling
Comment #14
christian.wiedemann commentedComment #15
just_like_good_vibesHello,
in this issue, we are trying to solve three different problems :
- no entity in layout plugin (the current issue subject)
- a missing peace in derivable contexts (to detect cardinality one in fields and inject the correct context requirement in order for sources to show up)
- a need to correct token source in order for it to work properly in any of our drupal plugin implementations.
Let's split work into three different issues, that will help to merge faster.
i will create the corresponding issues for Token and DerivableContext,
christian i will update the codes in the three issues, ok ?
Comment #16
just_like_good_vibesok, i created the two new issues,
i will report the corresponding codes to each of them and simplify the code of the current issue, ok for you Christian :) ?
- https://www.drupal.org/project/ui_patterns/issues/3465821
- https://www.drupal.org/project/ui_patterns/issues/3465823
Comment #17
just_like_good_vibesin this issue, we can also fix a typo in method
calculateDependenciesofComponentLayoutui_patterns_layout -> ui_patterns_layoutsComment #18
just_like_good_vibesHello,
now this work has be to rebased and corrected (phpstan, phpcs).
Christian, would you like me to do it ?
Comment #19
just_like_good_vibesComment #20
just_like_good_vibesI corrected the initial bug, but added a lot of other things :
- changed the discovery of layout plugins (deleted the hook in .module)
- BIG CHANGE : i introduced a new service in the main module to help cope with contexts, the service is used in the different Drupal plugins (blocks, field formatters, field layouts) to have clean and centralized way of doing context guessing. This has simplified plugins, which is a good thing (simplified service injection and simplified logic of context handling)
- refactored tests to have a base class for doing rendering tests : lot of new stuffs, inspired and extended from the work we started in ui_patterns_field_formatters.
- added tests for field_layout in different simple conditions: field_layout, layout_builder.. to be continued.
Comment #21
pdureau commentedComponentBlock in BlockLayout: ✅
ComponentBlock in Layout builder: ❌
Field Formatter in Layout builder: ❌
Field Formatter in Manage display: ✅
Layout in Layout builder: ❌
Comment #22
just_like_good_vibesit was working with drupal 10.3 (my test install) and not with drupal 11 (your test install)
after investigations, i have found we have been victims of https://www.drupal.org/project/drupal/issues/3303557.
corrected :) !
please re-test with drupal11
Comment #24
pdureau commentedMerged.
Follow up: #3467502: [2.0.0-beta2] ContextHelper cleaning
Comment #25
pdureau commentedComment #26
pdureau commentedComment #27
christian.wiedemann commented