首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带状态记录的admin-on-rest馈送

带状态记录的admin-on-rest馈送
EN

Stack Overflow用户
提问于 2018-05-22 15:11:47
回答 1查看 77关注 0票数 0

我有一个像这样的DisabledInput

代码语言:javascript
复制
<DisabledInput source="values" />

但是我想给这个字段提供一个状态变量。因为该状态变量可以随着用户交互而改变。更准确地说,在页面上有一个列表框,当用户向该列表框添加一个新值时,"values“状态变量会发生如下变化

"item1,item2,item3...“我想把这个状态变量作为数据提供给DisabledInput

代码语言:javascript
复制
this.state.values

我不知道该怎么做。也许有一种像下面这样的方法,但我不能这样做

代码语言:javascript
复制
<DisabledInput source="values" record={this.state.values} />

有可能吗?

EN

回答 1

Stack Overflow用户

发布于 2018-06-01 15:16:04

我使用了ArrayInput,如下所示。我之前没有意识到这个组件。

代码语言:javascript
复制
<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}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50461794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档