Plugins and the options syntax

In the past I have discovered weird behavior when dealing with options as array and options using the dotted syntax.

My assumption was that all dots resolve to nested arrays and vice-versa.
This means that:

'tobimori.dreamform' => [
  'actions' => [
    'email.from' => [
      'email' => 'mail@medienbaecker.com',
      'name' => 'Test'
    ]
  ],
],

Would be the same as:

'tobimori.dreamform' => [
  'actions' => [
    'email' => [
      'from' => [
        'email' => 'mail@medienbaecker.com',
        'name' => 'Test'
      ]
    ]
  ],
],

But apparently is it not. Since in my plugin settings I’ve specified my options in the second format, the first style doesn’t take effect.

What is the correct way for options to work? Always use arrays in the config.php?

personally I unroll all arrays like you did in the 2nd code example or just use the last level like this in the config files


'tobimori.dreamform.actions.email.from' => [
     'email' => 'mail@medienbaecker.com',
     'name' => 'Test',
],

yeah, but the issue is that not unrolling doesn’t merge correctly with the unrolled plugin defaults.

you used email.from in your config definitions? yes. that will cause issues. i have been there before and refactored to unroll that in my configs (or replace with email_from when i was to lazy).

No, I used the unrolled option in my plugin options and the dotted option in the site config and they were unable to be merged by Kirby

afaik. it works as long as you do not mix the dot notion in between as array keys. both when defining options in the plugin as well as when setting them in the config files.