Problem/Motivation

Actually the default provided configuration for module aren't correctly generated at module install/update. The Configuration provided by Form mode manager does provide a generic configuration when we enable new entities without submit newly the form mode manager configuration form.

Proposed resolution

Found a solution to provide a default state of configuration on each new entities activated.

Comments

woprrr created an issue. See original summary.

woprrr credited Berdir.

woprrr’s picture

Status: Active » Needs review
StatusFileSize
new2.42 KB
new51.71 KB

Seen on IRC with @berdir.

Berdir : that doesn't have anything to do with config schema if I understand that correctly. schema just defines the structure, it never automatically creates something. I don't really understand why not having a key is a problem, if you do $config->get("form_modes.$entity_type_id.to_exclude") ?: [] then you always at least have an empty array?
Berdir : You could implenent an event listener for new entity types and then update your config, but I don't get why that's necessary. you can just write your code so it can deal with a non-existing key, for example by wrapping it in a function/service that contains this logic
Berdir : replace type: XY with the definition that you have for that type
Berdir : you only need to define other types if you want to make them re-usable, or dynamic, e.g. based on plugins

After some investigations, I purpose this patch to Fixe the berdir warning about configuration schema and purpose all configurations options for knowed entities. If you need to add your custom entity and use Form mode/Form mode manager with your please update the configuration manually or with the following code :

$config = \Drupal::config('form_mode_manager.settings');
$config->set("form_modes.{$entity_type_id}.to_exclude", ['form_mode_machine_name': 'form_mode_machine_name']);
$config->save();

// Invalidate tags corresponding to entity_types (for entity_type_build()) / routes (for RouteSubscriber) / Local action / Local task (rendered),
\Drupal::service('cache_tags.invalidator')>invalidateTags([
  'local_action',
  'entity_types',
  'rendered',
  'routes',
]);

@Berdir I add you to correct me if I add an error in my schema and/or bad practice ;).

Config inspector check :

  • woprrr committed 3815895 on 8.x-1.x
    Issue #2891904 by woprrr, Berdir: Fix Default configuration provide by...
woprrr’s picture

Status: Needs review » Fixed

Merged Thanks @Berdir to your help ;)

Status: Fixed » Closed (fixed)

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