- Status changed to Needs work
about 1 year ago 3:26pm 21 April 2023 - π©πͺGermany hctom
Unfortunately this does not seem to work when
Allow each content item to have its layout customized.
is enabled and a per-entity layout wants to display a field with empty fields config that is not available in the default layout builder config for the an entity view mode.Steps to reproduce:
- Create a node type and enable layout builder for its
Full
display - Leave the
Full display completely empty (in layout builder as well as in normal field UI)
- Enable
Allow each content item to have its layout customized.
forFull
view mode - Create a node of that type
- Use the
Layout
tab to add fields to the layout and add a field that is empty, configure its empty field settings and save the per-node layout - Check the output -> the field is not outputted with the selected empty field behavior
If you add that field to the default layout for the
Full
view mode atadmin/structure/types/manage/NODE_TYPE/display/full/layout
, accessingnode/ID
throws the following error:TypeError: array_merge(): Argument #1 must be of type array, null given in array_merge() (line 215 of modules/contrib/empty_fields/empty_fields.module).
Accessing
node/ID/layout
displays everything the correct way - with empty field fallback and without any errors.So, I guess there is still some work to do :(
- Create a node type and enable layout builder for its
- π«π·France andypost
both cases from comment #30 should be added to test
- πΊπΈUnited States fskreuz
Roll in the similar one-liner change from 3192991 π Contrib module classes are overwritten Needs review since it was closed in favor of this issue.
- last update
5 months ago 1 fail - last update
5 months ago 1 pass - πΊπ¦Ukraine sickness29
Improved patch from #24 and used \Drupal\layout_builder\LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY instead.
This way we have build and all correct third party settings depending on entity, if it has overrides.
Also noticed test fail on D9.5, so made changes so it passes both cases. I checked locally and visually nothing changed, html output for field is the same, probably test engine method that were retrieving html changed.
Added functional javascript test as well to make sure empty fields working for default and custom layouts on test node type. - Status changed to Needs review
5 months ago 4:22pm 9 February 2024 - last update
5 months ago 2 pass - last update
5 months ago 2 pass - π«π·France andypost
-
+++ b/empty_fields.services.yml @@ -2,3 +2,9 @@ services: + empty_fields.event_subscriber: + class: Drupal\empty_fields\EventSubscriber\EmptyFieldsSubscriber + arguments: ['@plugin.manager.empty_fields'] + tags: + - { name: event_subscriber }
is needs change but for 10.2+ https://www.drupal.org/node/3357408 β
let's keep it as is
-
+++ b/src/EventSubscriber/EmptyFieldsSubscriber.php @@ -0,0 +1,109 @@ + protected $manager; ... + public function __construct(EmptyFieldsPluginManager $empty_fields_plugin_manager) { + $this->manager = $empty_fields_plugin_manager;
it should use constructor promotion
please convert patch to MR
-
- πΊπ¦Ukraine sickness29
Hi @andypost
thank you for your comments, MR created