Problem/Motivation

When using Field formatter source with an entity Label, the checkbox `Link label to the referenced entity` is checked, if uncheck will not be saved in config.

Only a manual import of config will save the 'uncheck version'.

Same for Field formatter, layout builder or Display Builder.

Steps to reproduce

On an entity display like articles with tags.

Set field_tags to component, pick a component with a slot
In component slot set "[Field] Formatter", Formatter: Label
Uncheck Link label to the referenced entity
Save

Go back, the link is checked again.

Config saved is:

        slots:
          label:
            sources:
              -
                source_id: 'field_formatter:node:article:field_tags'
                source:
                  type: entity_reference_label
                  settings:
                    link: true
                _weight: '0'
                third_party_settings: ''
                node_id: ''

If set link to false and import config, result is ok.

Go to the display, see Link label to the referenced entity is not checked.
Save
Then it is a link again

Check config, the settings is not there anymore.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Issue summary: View changes
smovs’s picture

Version: 2.0.16 » 2.0.x-dev
Assigned: Unassigned » smovs

smovs’s picture

Assigned: smovs » Unassigned
Status: Active » Needs review

Hey team!
I fixed the issue when link label to the referenced entity was not saved. Please review

The issue was:
ComponentSlotForm::afterBuild() discarded the return value of parent::afterBuild(), so a slot element's #value kept the raw POST data instead of the processed form values, and when ComponentForm::elementValidate() wrote that back over the whole ui_patterns subtree it erased everything the browser doesn't submit, including unchecked checkboxes like "Link label to the referenced entity"

mogtofu33’s picture

Assigned: Unassigned » mogtofu33
just_like_good_vibes’s picture

Hello here :)
that fix looks/seems necessary and nice.
please ping the issue to me @mogtofu33 after your review.
all the best

just_like_good_vibes’s picture

after #3618440: [task] add Playwright end-to-end tests to the pipeline will land in the codebase, i will probably add a new playwright test in addition to this work.
so let's wait for the playwright issue to be merged first.

just_like_good_vibes’s picture

hello guys, i have added the test for that specific use case and validated the fix from @smovs (thanks :) )
we could have added only a functional test for this use case (and phpunit would have allowed to test against different core versions if needed), but i have preferred to add a few lines to the existing field_formater playwright tests, so we don't have to pay the fixed cost of a new functional test and that new test cost less time in the pipeline.
new merge request is https://git.drupalcode.org/project/ui_patterns/-/merge_requests/541

just_like_good_vibes’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.