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

Created on 6 June 2023, about 1 year ago
Updated 3 April 2024, 3 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 3 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.69.0 2024