具有状态记录的休息管理员源



我有一个禁用输入,例如

<DisabledInput source="values" />

但是我想用状态变量输入此字段。因为此状态变量可以随着用户交互而更改。更准确地说,在页面上,有一个列表框,当用户向此列表框添加新值时,"values"状态变量会像

"项目1,项目2,项目3..."我想将此状态变量作为数据提供给禁用输入

this.state.values

我不知道该怎么做。也许有如下方法,但我做不到

<DisabledInput source="values" record={this.state.values} />

可能吗?

我按如下方式使用ArrayInput。 我以前没有意识到这个组件。

<SelectInput source='type'
choices={[
{ name: 'String', id: 'string' },
{ name: 'Enum', id: 'enum' },
{ name: 'Decimal', id: 'decimal' }
]}
onChange={event => {
const type = Object.values(event).slice(0, -1).join('');
this.setState({
listEditorVisible: type === 'enum',
regexEditorVisible: type === 'string',
decimalEditorVisible: type === 'decimal'
});
}}
/>
{this.state.listEditorVisible ?
<ArrayInput source='values'>
<SimpleFormIterator>
<TextInput source='name' />
</SimpleFormIterator>
</ArrayInput>
:
null}
{this.state.decimalEditorVisible ?
<div>
<NumberInput source="min" /><br />
<NumberInput source="max" /><br />
<NumberInput source="res" /><br />
<TextInput source="unit" />
</div>
:
null}

最新更新