Entity-CE-Display form sometimes displays form buttons for empty forms

Created on 16 May 2024, 6 months ago
Updated 5 June 2024, 6 months ago

Problem/Motivation

Thanks for bringing this home! When reviewing changes, I found an issue though:

📌 Improve entity display editing UI Needs work introduced this diff/check to see whether plugins implement a configuration form:

> if (!empty($field_row['plugin']['settings_edit_form']['form'])) {
> if (!empty($field_row['plugin']['settings_edit_form']['form']['settings'])) {

But a plugin does not have to use $form['settings']. Core field plugins do, but that is an implementation detail. Other plugins might e.g. simply introduce a "view-mode" dropdown using other form keys. For example, 📌 Allow rendering entity references with custom elements Active does.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇦🇹Austria fago Vienna

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

Merge Requests

Comments & Activities

  • Issue created by @fago
  • Assigned to junkuncz
  • Status changed to Needs work 6 months ago
  • Merge request !64Make settings checking more flexible → (Open) created by junkuncz
  • Pipeline finished with Canceled
    6 months ago
    Total: 49s
    #175004
  • Pipeline finished with Success
    6 months ago
    Total: 174s
    #175005
  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 6 months ago
  • 🇦🇹Austria fago Vienna
  • Pipeline finished with Success
    6 months ago
    Total: 182s
    #178001
  • Pipeline finished with Success
    6 months ago
    Total: 244s
    #178023
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    The currently committed code only checks if (!empty($field_row['plugin']['settings_edit_form']['form'])) {, so the original title has been fixed already.

    I believe this is a revert of some previous 'fix' - i.e. it equal to some situation last week, that had a comment saying it wasn't right. (I don't know in which issue though.) So now we are back to this previous not-right state.

    This is reproducible in the UI by taking an "Authored by" (uid) field and selecting the "Formatted: author" or "Formatted: entity ID" formatter. This is showing a form button, but there is no form.

    So.... changing title.

    I believe the cause of the original issue is that the form definition returned in

    $field_row['plugin']['settings_edit_form']['form'] = $plugin
          ->buildConfigurationForm($field_row['plugin']['settings_edit_form']['form'], $subform_state);
    

    is sometimes

    $configSubform = [
      'settings' => [],
    ]
    
    • this cannot be fixed by checking if element_children
    • doing reset() is weird.
    • I believe we can just decide that the above form definition is an invalid form array -- and therefore just expect the form to be fixed, instead of making up a strange check.

    New MR coming up with this new point (i.e. fixing the form definition). Tested.

  • Status changed to Needs review 6 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU
  • Status changed to Fixed 6 months ago
  • 🇦🇹Austria fago Vienna

    agreed. If a formatter returns

    $configSubform = [
    'settings' => [],
    ]

    then the formatter shoudl be fixed to not return an empty form like this. The MR does this just fine, thus merged. thx!

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

Production build 0.71.5 2024