mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 09:31:43 -05:00
rewrite Form.getLabel
This commit is contained in:
parent
fe13c451cf
commit
78af913820
1 changed files with 6 additions and 17 deletions
|
@ -516,26 +516,15 @@ class SmartForm extends Component {
|
|||
*/
|
||||
getLabel = (fieldName, fieldLocale) => {
|
||||
const collectionName = this.props.collectionName.toLowerCase();
|
||||
const defaultMessage = '|*|*|';
|
||||
let id = `${collectionName}.${fieldName}`;
|
||||
let intlLabel;
|
||||
intlLabel = this.context.intl.formatMessage({ id, defaultMessage });
|
||||
if (intlLabel === defaultMessage) {
|
||||
id = `global.${fieldName}`;
|
||||
intlLabel = this.context.intl.formatMessage({ id, defaultMessage });
|
||||
if (intlLabel === defaultMessage) {
|
||||
id = fieldName;
|
||||
intlLabel = this.context.intl.formatMessage({ id });
|
||||
}
|
||||
}
|
||||
const schemaLabel =
|
||||
this.state.flatSchema[fieldName] &&
|
||||
this.state.flatSchema[fieldName].label;
|
||||
const label = intlLabel || schemaLabel || fieldName;
|
||||
const label = this.context.intl.formatLabel({
|
||||
fieldName: fieldName,
|
||||
collectionName: collectionName,
|
||||
schema: this.state.flatSchema,
|
||||
});
|
||||
if (fieldLocale) {
|
||||
const intlFieldLocale = this.context.intl.formatMessage({
|
||||
id: `locales.${fieldLocale}`,
|
||||
defaultMessage: fieldLocale
|
||||
defaultMessage: fieldLocale,
|
||||
});
|
||||
return `${label} (${intlFieldLocale})`;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue