Field settings disappear if turn off the "Enable cloning" checkbox and save

Created on 6 June 2023, over 1 year ago
Updated 3 April 2024, 8 months ago

Problem/Motivation

Per-bundle field settings disappear if turn off the "Enable cloning" checkbox and save.

Steps to reproduce

1. Add some field settings to some bundle, eg node/article, with the checked "Enable cloning" checkbox and save.
2. Open the field settings again, uncheck the "Enable cloning" checkbox, and save.
3. See that all per-field settings disappeared.

Proposed resolution

All the settings should be kept, only

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

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

Merge Requests

Comments & Activities

  • Issue created by @murz
  • 🇦🇲Armenia murz Yerevan, Armenia

    In the form code, I've found that without this checkbox the config simply deletes:

      public function submitForm(array &$form, FormStateInterface $form_state) {
        $config = $this->configFactory->getEditable($this->getConfigId());
    
        if (empty($form_state->getValue('enabled'))) {
          $config->delete();
        }
        else {
          $fields = [];
          foreach ($form_state->getValue('fields') as $field_name => $data) {
            if (!empty($data['processor'])) {
              $fields[$field_name]['id'] = $data['processor'];
            }
          }
          $config->set('enabled', TRUE);
          $config->set('local_task_label', $form_state->getValue('local_task_label'));
          $config->set('fields', $fields);
          $config->save();
        }
      }
    

    I think it's a pretty strange behavior because sometimes we need just to disable and then enable back, without re-filling a lot of field settings.

    So, maybe add a separate action "Delete" instead of this trick?

    Additionally, maybe make the "local_task_label" field required? Because now it can be empty that produces an invisible tab item.

  • First commit to issue fork.
  • Assigned to orakili
  • Status changed to Needs review 8 months ago
  • 🇯🇵Japan orakili

    MR to separate deleting a configuration from enabling/disabling it: https://git.drupalcode.org/project/content_entity_clone/-/merge_requests/7

Production build 0.71.5 2024