对于以下内容:
<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元素是实现此目的的最佳方法。
谢谢。