fix: support radio inputs in admin system config form #724
Reference in New Issue
Block a user
Delete Branch "fix/admin-config-radio"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The admin Site Administration → Settings page threw a JS error, aborting all config-form init:
The system config form mapper (
web_src/js/features/admin/config.ts) only handledcheckbox,text,textarea, anddatetime-localelements. The fork'slanding_page.tmplintroducedtype="radio"inputs for the Mode field, sofillFromSystemConfig()fell through tounsupportedElement()and threw.Fix
Add radio support in both directions:
valueequals the config value.value; skip/null out unchecked radios in both collect paths so a group resolves to exactly one value (and unchecked options don't leak into the fallback pass).Tests
config.test.ts: added a radio-group sub-key case (landing.Mode=explore); full assertion object unchanged otherwise, proving no regression to existing element types.npx vitest run web_src/js/features/admin/config.test.ts→ 1 passed.Notes
.sublime-project/profile.ps1deletions, no lockfile committed.LandingPageType.Mode defaults to "" (Go zero value), and the template renders the home radio as checked for an empty Mode. The initial radio fill would evaluate home.checked = ("home" === "") = false, unchecking the default on a fresh install. Skip assignment when the config value is empty so the server-rendered selection is preserved. Adds a test for the empty-value case.Self-review before merge.
Reviewed:
assignConfigValueToFormElementandcollectConfigValueFromElement, ordered consistently (after checkbox, before datetime-local).collectConfigSubValues+ fallback loop incollectToFormData) skip/null unchecked radios, so a group resolves to exactly one value and doesn't leak into the second pass.Bug caught and fixed during review:
LandingPageType.Modedefaults to"", and the template renders thehomeradio checked for an empty Mode. The initial fill would have unchecked that default ("home" === ""→ false). Fixed by skipping assignment when the config value is empty, preserving the server-rendered selection. Added a regression test for the empty-value case.Tests:
npx vitest run web_src/js/features/admin/config.test.ts→ 1 passed (both non-empty and empty-default radio groups asserted).