[英]React-Admin: How can i get value of custom input inside 'Create' or 'Edit' Component
For the past days i've been searching for a way to get the value of my custom input component in the parameters of the create/edit component. 在过去的几天里,我一直在寻找一种在create / edit组件的参数中获取自定义输入组件的值的方法。
I created the component following Material UI's example in this link 我在此链接中按照Material UI的示例创建了组件
The component is rendered in the application but i can't get the value of the input. 该组件在应用程序中呈现,但我无法获得输入的值。 Here's how I add the custom input
这是我添加自定义输入的方法
<Create><SimpleForm> ... <CustomAutocompleteInput label="Main Subject" suggestions={subjectSuggestions} source="mainSubject"/> ... </SimpleForm></Create>
Can anyone help me? 谁能帮我?
you can set a reference to the dom node 您可以设置对dom节点的引用
<CustomAutocompleteInput
ref={node => {this.input = node;}}
label="Main Subject"
suggestions={subjectSuggestions}
source="mainSubject"
/>
...and then access the value by ...然后通过
let { value } = this.input
//or
let value = this.input.value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.