我正在使用react-admin 作为管理界面。在编辑表单中,我想显示编辑后的值(只是为了了解如何捕获表单更改后的值,稍后将显示来自 api 的数据以获取这些更改后的值)。我的代码如下(简化)
const Aside = ({ record }) => {
return (
<div style={{ width: 200, margin: '1em' }}>
<Typography variant="h6">Student details</Typography>
<Typography variant="body2">
{record && (
<Typography variant="body2">
{//Will Show current ArrayInput values here, Name/role of current students}
</Typography>
)}
</Typography>
</div>
)};
export const MyEdit = (props) => (
<Edit aside={<Aside />} {...props}>
<SimpleForm>
<ArrayInput source="students">
<SimpleFormIterator>
<TextInput source="name" /
<NumberInput source="role" />
</SimpleFormIterator>
</ArrayInput>
</SimpleForm>
</Edit>
);
Run Code Online (Sandbox Code Playgroud)
如何更新 ArrayInput 值的 onchange 之外的内容?