【发布时间】:2020-02-11 18:53:21
【问题描述】:
以下:
<ArrayInput source="slotCaps" label="Schedule Caps">
<SimpleFormIterator>
<Box display="flex">
<Box mr="0.5em">
<NumberInput source="cap" step={1}/>
</Box>
<Box ml="0.5em">
<SelectInput
source="period"
choices={[
{id: "0", name: "Day"},
{id: "1", name: "Week"},
{id: "2", name: "Month"}
]}
/>
</Box>
</Box>
</SimpleFormIterator>
</ArrayInput>
我明白了:
{
"name": "test 5",
"description": "test 5",
"slotCaps": [
{},
{}
],
"cap": 1,
"period": "0"
}
我期待:
{
"name": "test 5",
"description": "test 5",
"slotCaps": [
{"cap": 1, "period": "0"},
],
}
知道我做错了什么吗?有人可以解释一下我必须改变什么才能获得第二个变体吗? 谢谢。
编辑
不知道为什么,但出于某种原因,这可行:
<ArrayInput source="slotCaps" label="Schedule Caps">
<SimpleFormIterator>
<NumberInput source="cap" step={1}/>
<SelectInput
source="period"
choices={[
{id: 1, name: "Day"},
{id: 2, name: "Week"},
{id: 3, name: "Month"}
]}
optionValue={"name"}
/>
</SimpleFormIterator>
</ArrayInput>
如果有人知道如何使第一个变体工作,请提供您的意见。我需要正确格式化字段,看起来使用 Box 元素是实现这一目标的最佳方式。
谢谢。
【问题讨论】:
标签: react-admin