自定义字段不呈现传递的标签
Custom Field doesn't render passed label
我仍在弄清楚一切是如何运作的。但我绝对喜欢分页和过滤的简单性!
这是我的问题:
我正在尝试构建一个相对简单的自定义字段。它应该从数组中呈现一堆字符串:
const ArrayField = ({ source, record = {} }) => {
const hasItems = has(record, source);
return (
<div>
{hasItems && record[source].map(item => <div key={item.id}>{item.designation}</div>)}
</div>
);
};
ArrayField.propTypes = {
label: PropTypes.string,
record: PropTypes.object,
source: PropTypes.string,
};
文档中是这样写的:"Tip: The label attribute isn’t used in the render() method, but admin-on-rest uses it to display the table header."
但是,如果我这样传递我的标签,则不会显示该标签:
export const PlaylistShow = (props) => (
<Show title={<PlaylistTitle/>} {...props}>
<SimpleShowLayout>
<TextField source='id' />
<TextField label='Name' source='designation' />
<ArrayField label='Media' source='playlistItems' />
</SimpleShowLayout>
</Show>
);
有没有我遗漏的步骤?不幸的是,我无法从文档中弄清楚。
期待您的回答:)
来自关于 custom inputs 的文档:
Tip: To avoid repeating them each time you use the component, you should define label and addLabel as defaultProps
我仍在弄清楚一切是如何运作的。但我绝对喜欢分页和过滤的简单性!
这是我的问题:
我正在尝试构建一个相对简单的自定义字段。它应该从数组中呈现一堆字符串:
const ArrayField = ({ source, record = {} }) => {
const hasItems = has(record, source);
return (
<div>
{hasItems && record[source].map(item => <div key={item.id}>{item.designation}</div>)}
</div>
);
};
ArrayField.propTypes = {
label: PropTypes.string,
record: PropTypes.object,
source: PropTypes.string,
};
文档中是这样写的:"Tip: The label attribute isn’t used in the render() method, but admin-on-rest uses it to display the table header."
但是,如果我这样传递我的标签,则不会显示该标签:
export const PlaylistShow = (props) => (
<Show title={<PlaylistTitle/>} {...props}>
<SimpleShowLayout>
<TextField source='id' />
<TextField label='Name' source='designation' />
<ArrayField label='Media' source='playlistItems' />
</SimpleShowLayout>
</Show>
);
有没有我遗漏的步骤?不幸的是,我无法从文档中弄清楚。
期待您的回答:)
来自关于 custom inputs 的文档:
Tip: To avoid repeating them each time you use the component, you should define label and addLabel as defaultProps