Clean up CE display settings on save (or earlier)

Created on 22 May 2024, 7 months ago
Updated 10 September 2024, 3 months ago

Problem/Motivation

Steps to reproduce

Scenario:

I have some (multi-value) field, selected with some Core Field formatter that has a settings form. (Example: link field in our standard tests' link paragraph.)

These have settings, e.g.

  field_link:
    formatter: raw
    name: link
    is_slot: false
    weight: 0
    region: content
    configuration:
      is_slot: false
      settings:
        trim_length: '80'
        url_only: '1'
        url_plain: 0
        rel: 0
        target: 0

Now, in the respective "Manage Custom Elements" tab, I change to "Raw" formatter, save and export the CE display.

The "settings" sub array is not removed from the exported values, even though it is unused.
Note - there is nothing special about the "settings" sub array. If we do the inverse, e.g. we change a field formatter of a type that has a "mode" configuration, into a Core field formatter which does not have "mode" (only "settings), then the "mode" value also is not removed, even though it is unused.

Proposed resolution

Prune the 'configuration' array, sometime. (Just before saving, or at an earlier point.)

Make sure 'is_slot' is not inside the configuration array; only the 'outer' is_slot value is used/valid. (This is done already, in another )

📌 Task
Status

Active

Version

3.0

Component

Code

Created by

🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

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

Comments & Activities

  • Issue created by @roderik
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    This might be done after 📌 Change configuration structure for CE display 'components' Active is done.

    Also / related / check: we should just remove the whole 'hidden' section if #3455435 didn't do that yet.

  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    What is mentioned in the previous comment, is done. Except that 'hidden' is still output as "null", for reasons (that I might look up again if I feel like it)....

    I'm leaving this open for a doublecheck:
    - After 📌 Simplify entity-ce-display form and AJAX logic Active is done: can we / have we got rid of the 'region' value?

  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Done:

    • The is_slot duplication is done (by adding it to the array_diff_key() in EntityCustomElementsDisplayEditForm::copyFormValuesToEntity())
    • 'region' is (likely) removed in 📌 Simplify entity-ce-display form and AJAX logic Active , along with the empty 'hidden' key/li>

    Left to do: re-testing the change from a 'core' formatter to e.g. "raw" and seeing if the 'settings' are gone.

  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Just tested: there is nothing special about Core field formatters here. Any settings in the "configuration" array are not 'cleaned up' / stick arouond, when we change the formatter type from one type that has a certain configuration value, to another type that does not.

    We should clean this up, but it doesn't feel super urgent to me. The unnecessarily-saved values don't get in the way of anything; they are just ugly.

    So I don't think we have to do this before stable release.

Production build 0.71.5 2024