我有这样的CheckboxGroupInput
字段:
<CheckboxGroupInput source="fruits" choices={[
{ 'name': 'apples' },
{ 'name': 'pears' }
]} optionValue='name'/>
当用户同时选择两个选项时,会为fruits
字段生成json赞:
'fruits': ['apples','pears']
我想使用List
将其显示在ChipField
中,这需要我没有的source
,因为json是纯字符串数组。
如果json看起来像fruits:[{'name':'apples'}, {'name':'pears'}]
,则源将为“名称”>
如何告诉<ArrayField source='fruits'> <SingleFieldList> <ChipField source='???' /> </SingleFieldList> </ArrayField>
如何显示带有
ChipField
的纯字符串数组的内容OR
CheckboxGroupInput
生成对象数组而不是字符串数组?我有一个CheckboxGroupInput字段,如下所示:
查看演示代码总是一个好主意。通过从react-admin演示代码中修改了自定义SimpleChipField
,我设法创建了一个名为ChipField
的自定义组件。它显示整个record
作为标签。