是否可以在消息和标题中引用除 id 字段之外的其他字段?
Is it possible to reference another field than the id field in messages and titles?
我希望屏幕的标题以及删除确认消息使用与 id 不同的字段来向用户标识记录,因为 id 格式不是很人性化。
我知道如何自定义消息和标题的文本。但是,我不知道如何在构造文本消息时访问 id 参数以外的其他字段。
这可能吗,还是我需要将消息匿名化以不包含对实际记录的引用?
This is an illustration of the delete message, where I'd like something nicer for the user, like eg. the e-mail of the employee to delete, instead of the random string that is the id value.
在页眉中,您可以使用记录中的任何字段:
https://marmelab.com/react-admin/Show.html#page-title
const PostTitle = ({ record }) => {
return <span>Post {record ? `"${record.title}"` : ''}</span>;
};
export const PostShow = (props) => (
<Show title={<PostTitle />} {...props}>
...
</Show>
);
在删除确认对话框中,现在无法将id字段更改为其他字段,我认为这种可能性仅在开发中:
https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.js
我希望屏幕的标题以及删除确认消息使用与 id 不同的字段来向用户标识记录,因为 id 格式不是很人性化。
我知道如何自定义消息和标题的文本。但是,我不知道如何在构造文本消息时访问 id 参数以外的其他字段。
这可能吗,还是我需要将消息匿名化以不包含对实际记录的引用?
This is an illustration of the delete message, where I'd like something nicer for the user, like eg. the e-mail of the employee to delete, instead of the random string that is the id value.
在页眉中,您可以使用记录中的任何字段: https://marmelab.com/react-admin/Show.html#page-title
const PostTitle = ({ record }) => {
return <span>Post {record ? `"${record.title}"` : ''}</span>;
};
export const PostShow = (props) => (
<Show title={<PostTitle />} {...props}>
...
</Show>
);
在删除确认对话框中,现在无法将id字段更改为其他字段,我认为这种可能性仅在开发中: https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.js