Skip to content

Commit

Permalink
[ASL-4474] Allow passing data for mustache templates when rendering f…
Browse files Browse the repository at this point in the history
…ield labels, hints and errors.
  • Loading branch information
jeff-horton-ho-sas committed Feb 19, 2024
1 parent 2794938 commit 8504282
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fieldset/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,12 @@ function Field({
hint = <Markdown unwrapSingleLine={true}>{ hint }</Markdown>;
}

const snippetProps = props.formatters?.[name]?.renderContext ?? {};

return <Component
label={isUndefined(label) ? <Snippet>{`fields.${name}.label`}</Snippet> : label}
hint={isUndefined(hint) ? <Snippet optional>{`fields.${name}.hint`}</Snippet> : hint}
error={error && <Snippet fallback={`errors.default.${error}`}>{`errors.${name}.${error}`}</Snippet>}
label={isUndefined(label) ? <Snippet {...snippetProps}>{`fields.${name}.label`}</Snippet> : label}
hint={isUndefined(hint) ? <Snippet optional {...snippetProps}>{`fields.${name}.hint`}</Snippet> : hint}
error={error && <Snippet fallback={`errors.default.${error}`} {...snippetProps}>{`errors.${name}.${error}`}</Snippet>}
value={fieldValue}
onChange={onFieldChange}
name={prefix ? `${prefix}-${name}` : name}
Expand Down

0 comments on commit 8504282

Please sign in to comment.