简体   繁体   English

React-Admin:如何在“创建”或“编辑”组件中获取自定义输入的值

[英]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.

相关问题 如何以编程方式更改 react-admin 创建组件中的记录 - How do I programmatically change the record inside a react-admin create component 如何使用#react-admin创建自定义页面而不使用登录页面等菜单侧栏? - How can I create a custom page with #react-admin without the menu sidebar like login page? React-Admin 中自定义输入的更新值未以编辑形式提交 - Updated Value of custom Input in React-Admin not getting submitted in edit form 如何在 react-admin 的创建按钮上制作图标“+”? - How can I make icon '+' on create button in react-admin? React-Admin:如何在没有 `source` 的情况下访问值? - React-Admin: How can I access a value without `source`? React-Admin:如何在 1 更改后编辑另一个组件值(例如,小计+折扣=总计)? - React-Admin: How to edit another Component value after 1 has changed (eg, subtotal+discount=total)? react-admin 编辑组件不工作 - react-admin edit component is not working react-admin中自定义字段组件如何添加label - How to add label to custom field component in react-admin 如何在 React-Admin 中为自定义组件更新 state - How to update the state for a custom component in React-Admin 我如何使用像 react-image-editor 这样的组件在 react-admin 中裁剪图像 - How can I use a component like react-image-editor for cropping an image in react-admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM