reactjs - 在编辑输入中加载嵌套资源属性值
问题描述
我正在使用 React Admin 为我的 API 生成 CRUD。
在我的 API 中,我有一个资源 Person,其中包含一对一关系上的嵌套资源配置文件。创建和编辑人员时,我的 API 允许直接发送个人资料的属性,并创建或编辑嵌套的个人资料资源。
这是我GET
对一个人执行 a 时收到的内容,也是我执行 a PUT
or时可以发送到我的 API 的内容POST
person: {
profile: {
firstName,
lastName
},
...otherPersonProperties
}
在资源 Person 的 Edit 页面上,我显示了与配置文件嵌套资源相关的输入字段:
<Edit {...props}>
<SimpleForm>
<TextInput source="profile.firstName" {...props} />
<TextInput source="profile.lastName" {...props} />
</SimpleForm>
</Edit>
我本来希望与嵌套资源配置文件相关的文本输入预填充获取的值,但输入为空。
是否无法将嵌套资源属性的值加载到 TextInput 中?
编辑
这就是 fetch 带给我的:
@context: "/api/contexts/Person"
@id: "/api/persons/1004"
@type: "Person"
user: "/api/users/28"
profile: {
@id: "/api/profiles/1004"
@type: "Profile"
firstName: "trainee2_firstName"
lastName: "trainee2_lastname"
}
但这就是 formData 里面的内容:
@context: "/api/contexts/Person"
@id: "/api/persons/1002"
@type: "Person"
id: "/api/persons/1002"
user: "/api/users/28"
profile: "/api/profiles/1002"
似乎 React Admin 不明白我希望将配置文件字段值注入表单中。
解决方案
推荐阅读
- html - 如何计算` `元素的高度
- mongodb - 如何在 MongoDB 中将待办事项或更多内容保存在创建它们的用户的数组属性中?
- oracle - Oracle如何更新一张表中的多列
- python - TypeError:“NoneType”对象不可调用(Pytorch)
- linux-kernel - 应用补丁文件时未定义的引用
- python - Django 如何组合不同的上下文并将其传递给模板
- python - 如何从特定用户 django python 获取数据
- r - 有人可以解释这些代码行的含义吗?
- javascript - 加入嵌套数组并输出逗号分隔列表
- python - Plotly 多行数据框