- First commit to issue fork.
- 🇦🇹Austria hudri Austria
I think I've got a related problem: My module has theme-specific settings. Previously I just my modules config settings into the root of theme.settings.yml. Inspired by the shortcut module, I now wanted to clean this up and move it into third party settings. Basically I wanted to update my config from
third_party_settings: shortcut: module_link: true tailwind_jit: compile_html_requests: true html_input_file: 'foo.css' compile_ajax_requests: true ajax_input_file: 'bar.css'
to a proper schema
theme_settings.third_party.tailwind_jit: type: mapping label: 'Tailwind JIT settings' mapping: compile_html_requests: type: boolean label: 'Compile HTML requests' html_input_file: type: path label: 'Uncompiled CSS input file for HTML requests' compile_ajax_requests: type: boolean label: 'Compile Ajax requests' ajax_input_file: type: path label: 'Uncompiled CSS input file for Ajax requests'
and proper third party settings
third_party_settings: shortcut: module_link: true tailwind_jit: compile_html_requests: true html_input_file: 'foo.css' compile_ajax_requests: true ajax_input_file: 'bar.css'
The form hook is something like
function tailwind_jit_form_system_theme_settings_alter(&$form, FormStateInterface $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), ]; /* ...more form elements here... */ }
This does not work correctly, there are two problems:
1) The schema is not used/validated, the boolean value is still stored as (int) 0 / 1 and not as (bool) true / false
2) When submitting the form, it saves all my values, but wipes the existing config from shortcut module.Reading @berdir's comment, is shortcut a bad example? Should I avoid third party settings for themes at all?