1

How to I properly implement third party settings for a theme, without clearing 3rd party settings from other modules?

E.g. my site has a gin.settings.yml with

third_party_settings:
  shortcut:
    module_link: true

Now I install my module, which implements hook_form_system_theme_settings_alter :

function tailwind_jit_form_system_theme_settings_alter(&$form, $form_state, $form_id = NULL) {
  $form['third_party_settings']['tailwind_jit'] = [
    '#type' => 'details',
    '#open' => TRUE,
    '#title' => t('Tailwind CSS Just-in-time compilation'),
    '#tree' => TRUE,
    '#parents' => ['third_party_settings', 'tailwind_jit'],
  ];
  $form['third_party_settings']['tailwind_jit']['compile_html_requests'] = [
    '#type' => 'checkbox',
    '#title' => t('Compile HTML requests'),
    '#default_value' => theme_get_setting('third_party_settings.tailwind_jit.compile_html_requests', $themeToBeConfigured),
  ];
}

This works and saves my config settings BUT it also wipes the pre-existing shortcut.module_link setting from shortcut module, leading to a config like

# shortcut settings are now missing
third_party_settings:
  tailwind_jit:
    compile_html_requests: 1

How to I properly implement 3rd party settings in hook_form_system_theme_settings_alter?

1

0

Your Answer

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

Browse other questions tagged or ask your own question.