Skip to content

Commit 0f70152

Browse files
authored
feat(templates): Allow customization per-field by using string key from registry
Fixes rjsf-team#3695
1 parent 1576c27 commit 0f70152

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/utils/src/getTemplate.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export default function getTemplate<
1818
if (name === 'ButtonTemplates') {
1919
return templates[name];
2020
}
21+
// Allow templates to be customized per-field by using string keys from the registry
22+
if (Object.hasOwn(uiOptions, name) && Object.hasOwn(templates, uiOptions[name])) {
23+
return templates[uiOptions[name]]
24+
}
2125
return (
2226
// Evaluating uiOptions[name] results in TS2590: Expression produces a union type that is too complex to represent
2327
// To avoid that, we cast uiOptions to `any` before accessing the name field

0 commit comments

Comments
 (0)