Allow to get the label from the field_display_label module

Created on 14 February 2023, almost 2 years ago

Problem/Motivation

I love the 2.x version where you guys provided new formatters!
One question I have is how to allow the label to be set from another module https://www.drupal.org/project/field_display_label β†’
I tried adding a new UiPatterns source, but could not get the proper info there.
So thought on altering the code from the formatter to allow to have the label from the third party settings.
Not sure if this is the place to fix this, but you can always point me to the correct place.

Steps to reproduce

  1. Install field_display_label β†’ module
  2. Set another field label in the field setting for a field
  3. Set a pattern for that field and use the label
  4. See that the label rendered is the original label from the field config and not the label from the third party setting.

Proposed resolution

Allow to get the label from the third party setting from the field_display_label module when entered.

Remaining tasks

Discuss if this is the correct way and place to fix this
Create a patch if this is the place
Review patch when there is a patch

User interface changes

-

API changes

-

Data model changes

-

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @tim-diels
  • Status changed to Needs review almost 2 years ago
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    I provide a patch as starting point on what to achieve, but It feels like this is not the best way to provide this.
    This patch checks if the module field_display_label is installed and overwrites the label with the display label when there is one.

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Best would be to have a plugin for the module to have the display label in the list of the following:

  • πŸ‡«πŸ‡·France duaelfr Montpellier, France

    Thank you for reporting this!

    I recently faced a quite similar issue when trying to add custom properties from a custom source plugin. The thing is that the way UI Patterns is built, the source only provide the list of available items but never the associated values. I think that's a big flaw in the design that should be fixed upstream. This way it would allow any module to add sources and reduce the burden of maintaining multiple integrations with a ton of potential contrib modules.

    I opened ✨ [2.0.0-alpha1] Source plugins should also provide SourceField value Needs review to get this idea running. In the meantime we could integrate this here. I'd prefer it to be a new option in the least instead of overriding the existing label. What do you think?

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    I sure follow what you say. I was trying to build a source plugin, but was not able to get the appropriate information. So went the quick and dirty way and override the existing label.

    I would indeed like to have the options in the list. Every module could provide its own plugin and will be displayed there.

    But at this point I failed in getting that.
    Great to see you opened an issue with ui patterns to see if it could provide more info for the plugins. Let’s see what happens there? I indeed think the current solution is not the way to go. Let’s postpone this until the other issue gets picked up and fixed?

  • Status changed to Needs work almost 2 years ago
  • πŸ‡«πŸ‡·France duaelfr Montpellier, France

    We could merge something now then remove/refactor it once the UI Patterns issue lands. It's unlikely to be done in the current major version so we might need to wait quite some time before it gets picked.

    If we were to merge it in UI Patterns Field Formatter, I'd like to see it as a new field option so we should add a line in \Drupal\ui_patterns_field_formatters\Plugin\UiPatterns\Source\FieldPropertiesSource::getSourceFields() (let's call it _display_label) then add an entirely new condition in the formatter instead of overriding the existing one like you did.

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    I love the idea. Great thinking! Hope to have some time soon to get the patch refactored.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Ok had to fix another issue, so thought on rewriting this in the same time.
    I added the field_display_label to the metadata properties and added it to both the formatters.

  • πŸ‡§πŸ‡ͺBelgium tim-diels Belgium πŸ‡§πŸ‡ͺ

    Added MR for easier follow up.

  • πŸ‡¦πŸ‡ΊAustralia NicolasH

    Nice! Can confirm it's working here.

  • Assigned to duaelfr
  • πŸ‡«πŸ‡·France pdureau Paris

    Hi Duaelfr, I take care of 1.0.x reviews, and I assign the 2.0.x review to you.

  • πŸ‡«πŸ‡·France duaelfr Montpellier, France

    Sorry for the massive delay...
    Rebased and added dependency injection because I like that better ;)
    Thanks!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024