Edit
视图未按预期填充字段,我无法弄清楚原因。 REST端点返回数据,同样在Create
期间工作正常,但似乎Edit
没有使用这些值(它是相同的source
)。很奇怪,因为name
输入已填充,但可能来自List
视图。
尝试使用示例http://jsonplaceholder.typicode.com
并且它有效,所以我猜测我的服务器在某种程度上是错误的。
有什么想法吗?
以下是我的服务器的响应方式:
Request URL:http://localhost:5000/api/facility/O42f026921e0f551819b4a5413ed67487
Request Method:GET
Status Code:200 OK
Remote Address:[::1]:5000
Referrer Policy:no-referrer-when-downgrade
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://localhost:3000
Content-Type:application/json; charset=utf-8
Date:Sun, 28 Jan 2018 21:26:34 GMT
Server:Kestrel
Transfer-Encoding:chunked
Vary:Origin
accept:application/json
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.9,pt-BR;q=0.8,pt;q=0.7
authorization:R887b9a67f1d71a69a3ac7d39b65853c6
Connection:keep-alive
content-type:application/json
Host:localhost:5000
Origin:http://localhost:3000
Referer:http://localhost:3000/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
这是我的编辑视图:
export const FacilityEdit = (props) => (
<Edit title={<FacilityName />} {...props}>
<TabbedForm>
<FormTab label="resources.tabs.summary">
<ReferenceInput source="companyId" label='resources.company.name' reference="company" allowEmpty>
<AutocompleteInput optionText={choice => `${choice.name}`} />
</ReferenceInput>
<TextInput source="name" label='resources.facility.fields.name' />
<EmailField source="createdBy" label='resources.fields.createdBy' />
<DateField source="createdAt" label='resources.fields.createdAt' />
</FormTab>
<FormTab label="resources.tabs.address">
<NumberInput source="address.zipCode" label='resources.address.fields.zipCode' />
<TextInput source="address.address1" label='resources.address.fields.address1' />
</FormTab>
</TabbedForm>
</Edit>
);
答案 0 :(得分:0)
好的,发现了问题。在List
视图中我有一个id
,但在Edit
视图中我有一个itemId
,这导致了问题。