Problem/Motivation

In 8.2.x, when a field is disabled under "Manage display" for an entity, the label display settings still appear to be configurable. However, the user's selection is not actually stored anywhere and therefore lost.

The label settings are lost if selected for a hidden field
(gif provided by @alexpott)

In 8.3.x following #2796581: Fields must store their region in entity displays, this also happens for the formatter selection.
Formatter settings also will be lost

This bug might not appear that impactful at first since it's for configuring fields that are not displayed, but the problem is that this also impacts the data when fields are moved between disabled and an enabled region, which results in lost input that the user did not expect.

Steps to reproduce

  1. On /admin/structure/types/manage/article/display, move the Tags field to disabled and save the form.
  2. Change the "Label" or "Format" options for the Tags field and save again. The change is not actually saved.

Proposed resolution

Do not show field settings that are not saved for disabled fields.

No formatter or label settings shown for disabled fields

The solution will need to support all three of tabledrag, non-tabledrag, and no-js workflows for the form.

A different solution would be to actually store the configured settings for disabled fields, but that would require a data model change as well, and as @alexpott points out there is also an advantage to simply having fewer options on this form.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm created an issue. See original summary.

xjm’s picture

Issue summary: View changes

xjm credited alexpott.

xjm credited catch.

xjm’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

capysara’s picture

Issue tags: +FLDC17

I'm going to triage this.

capysara’s picture

Issue summary: View changes
capysara’s picture

I was able to reproduce this in 8.4.x locally. Following steps in the summary:
Steps to reproduce
On /admin/structure/types/manage/article/display, move the Tags field to disabled and save the form.
Change the "Label" or "Format" options for the Tags field and save again. The change is not actually saved.

I also updated the description--changed "manage form display" to "manage display" to more accurately reflect what's reported in the gif and the steps to reproduce.

However, a similar issue exists in Manage form display when the field is moved to Disabled and the widget type is not saved.
Steps to reproduce
On /admin/structure/types/manage/article/form-display, move the Tags field to disabled and save the form.
Change the "Widget" options for the Tags field and save again. The change is not actually saved.

capysara’s picture

Issue tags: +Triaged for D8 major current state
swentel’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
1.41 KB

So one option is to use the 'visually-hidden' class which really is the easiest one, but maybe not the prettiest :)

I've played with #access, but that's not an option since the javascript needs the format select element to be there. Unless we start changing that of course.

Needs tests. If we can agree on using the css trick, I can quickly write a test for it.

xjm’s picture

Issue summary: View changes
Issue tags: +Triaged core major

Traiged with @catch, @cilefen, @alexpott, @Cottser, and @lauriii. Since this bug is about lost user input on an administrative site builder page, it might not seem that big of a deal. However, it is lost user input, and the user does not expect it. The usability bug occurs when configuring a field in the disabled section and then moving it -- your configurations are stripped away.

Sine there is not that much to re-enter and since it impacts major fields, we discussed that it might only be normal, but it is a loss of user input further exposed by the field UI improvements, that could make your site look goofy.

Thanks @capysara for finding this issue and veriying it! Adding issue credit.

xjm’s picture

Status: Needs review » Needs work

Hm, I don't think these fields should just be visually hidden. They would still be available to non-visual browsers, making an accessibility bug. They would also be available to anything altering the form. They should not be available at all in the form, because no data is stored for them. The disabled blocks should just be empty rows until they're dragged back to the enabled block list.

sathish.redcrackle’s picture

Priority: Major » Normal

The patch dint worked for me. I checked the issue and found the below code where they are removing the compound if the field is in hidden state and not saving any value.
as @xjm suggested why we need to change the value of the field display setting which is in hidden stage? since it is not viewable to user.
So i am changing the priority to 'Normal'

      if ($values['region'] == 'hidden') {
        $entity->removeComponent($field_name);
      }
      else {
        $options = $entity->getComponent($field_name);

        // Update field settings only if the submit handler told us to.
        if ($form_state->get('plugin_settings_update') === $field_name) {
          // Only store settings actually used by the selected plugin.
          $default_settings = $this->pluginManager->getDefaultSettings($options['type']);
          $options['settings'] = isset($values['settings_edit_form']['settings']) ? array_intersect_key($values['settings_edit_form']['settings'], $default_settings) : [];
          $options['third_party_settings'] = isset($values['settings_edit_form']['third_party_settings']) ? $values['settings_edit_form']['third_party_settings'] : [];
          $form_state->set('plugin_settings_update', NULL);
        }

        $options['type'] = $values['type'];
        $options['weight'] = $values['weight'];
        $options['region'] = $values['region'];
        // Only formatters have configurable label visibility.
        if (isset($values['label'])) {
          $options['label'] = $values['label'];
        }
        $entity->setComponent($field_name, $options);
      }

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

xjm’s picture

Priority: Normal » Major
Issue tags: -Triaged for D8 major current state

Restoring priority; this issue was confirmed to be major by the Drupal core committers.

capysara’s picture

What if we make the form fields disabled instead of hiding them altogether?

I found that when I hid them, the column widths adjusted to space out evenly, and, in some cases, it was annoying because it was a pretty significant jump. It's really noticeable on the default Basic page when you move the Body field to disabled, but leave Links displayed.

If disabling them isn't the right approach, I'll work on hiding them, but I wanted to check on it.

Here's POC for the disabled fields:

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

John Pitcairn’s picture

A different solution would be to actually store the configured settings for disabled fields, but that would require a data model change as well.

It's pretty annoying as a site builder if you want to disable a few fields to test out some layout variation, then you re-enable them only to find you also have to reconfigure them. If you have a lot of formatter 3rd-party add-ons that's very tedious, and you will forget something.

I also have a more advanced use case - allow layout builder content field blocks to use the configured settings as defaults, and optionally hide that whole formatter mess from site editors who are using layout builder. I've just been working on a proof of concept that stalled on this issue.