While the core theme will change the Label of a field to match the ui:title in the UISchema, the material UI view does not.
ErrorSchema choiceAge field says Age of personAge field says AgeThe material UI view picks up the ui:title of a field from the UI schema
The material UI view picks up the default title of the field from the schema
whatever version the playground is running
Maybe it's related to this line in ObjectFieldTemplate not using the ui:title?
When I ran into this issue, I noticed
https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/StringField.js#L30
https://github.com/rjsf-team/react-jsonschema-form/blob/master/packages/core/src/components/fields/StringField.js#L47
when I traced why the ui:title wasn't working.
I ended up making a wrapper component for StringField. Here's a winded example
import React, { memo, } from 'react';
import Form, { Theme, } from '@rjsf/material-ui';
const {
fields: muiFields,
} = Theme;
const {
StringField: MUIStringField,
} = muiFields;
const StringField = memo( function StringFieldComponent( props ) {
let _props = props;
const title = props?.uiSchema?.['ui:title'];
if ( title ) {
const {
schema,
} = props;
_props = {
...props,
schema: {
...schema,
title,
},
};
}
return <MUIStringField {
..._props
} />;
} );
const fields = {
StringField,
};
export default memo( function FormBuilderComponent( props ) {
return <Form {...{
fields,
...props,
}} />;
} );
Some additional notes:
concise playground example ... just toggle between themes.
Yeah, that's unfortunate. Would definitely be open to merging a fix for this (both for the material-ui theme, or other themes as well).