diff --git a/web-console/src/components/auto-form/auto-form.tsx b/web-console/src/components/auto-form/auto-form.tsx index 357046876afd..c63f7a7bc500 100644 --- a/web-console/src/components/auto-form/auto-form.tsx +++ b/web-console/src/components/auto-form/auto-form.tsx @@ -72,6 +72,10 @@ export interface Field { hide?: Functor; hideInMore?: Functor; valueAdjustment?: (value: any) => any; + /** + * An optional callback to transform the value before it is set on the input + */ + adjustValue?: (value: any) => any; adjustment?: (model: Partial, oldModel: Partial) => Partial; issueWithValue?: (value: any) => string | undefined; @@ -378,12 +382,14 @@ export class AutoForm> extends React.PureComponent const disabled = AutoForm.evaluateFunctor(field.disabled, model, false); const intent = required && modelValue == null ? AutoForm.REQUIRED_INTENT : undefined; + const adjustedValue = field.adjustValue ? field.adjustValue(shownValue) : shownValue; + return (