2

Module A defines the following schema in module_a.schema.yml.

module_a.settings.api:
  type: config_object
  label: API settings
  mapping:
    store:
      type: string
      label: Store code
    credentials:
      type: mapping
      label: Credentials
      mapping:
        username:
          type: string
          label: Username
        password:
          type: string
          label: Password

Module B extends the Module A configuration form and defines additional schema properties in module_b.schema.yml.

module_a.settings.api:
  mapping:
    additionl_one:
      type: mapping
      label: Additional one
      mapping:
        additionl_one_sub:
          type: label
          label: Additional one sub

The definition from module_b.schema.yml isn't picked up by Drupal. I'm checking with config_inspector and proving it by the fact that the new properties can't be translated.

Available articles/tutorials out there are doing the same thing but seems like this is either outdated or never worked:

5
  • 1
    You can definitely extend configuration - it's the basis of the entire typed data API on which configuration is built. Unfortunately I don't have the answer on how to fix it, but maybe you shouldn't redefine the entire mapping, but rather try extending module_a.settings.ap. additionl_one_sub as module_a.settings.api has already been defined as a mapping in module A, so you shouldn't need to redefine it as a mapping in module B.
    – Jaypan
    Nov 23, 2019 at 0:49
  • @Jaypan yes, it supposed to work but - it doesn't. Also, tried defining the immediately nested one but, without effect. Nov 23, 2019 at 9:43
  • 1
    I have just spent a number of hours working on this - and I don't believe it's possible. I think my tutorial that is linked to used the method from the first.
    – Jaypan
    Mar 7, 2020 at 21:04
  • @Jaypan yeah, didn't manage to make it work either, probably a d.o issue should be opened. Mar 9, 2020 at 9:25
  • @xandreadx provided a working solution below.
    – Jaypan
    Feb 28, 2021 at 20:38

2 Answers 2

2

Use hook_config_schema_info_alter().

function module_b_config_schema_info_alter(&$definitions) {
  $definitions['module_a.settings.api']['mapping']['additionl_one'] = [...];
}
1
  • 1
    Thanks, I've come back to this problem multiple times in the past, and finally a solution!
    – Jaypan
    Feb 28, 2021 at 20:37
0

I think that I have found a solution, it seems that you need to add 'type: config_object' when extending:

module_a.settings.api:
  type: config_object
  mapping:
    additionl_one:
      type: mapping
      label: Additional one
      mapping:
        additionl_one_sub:
          type: label
          label: Additional one sub
1
  • I didn't find that this worked.
    – Jaypan
    Feb 28, 2021 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.