[英]How to handle two different Select inputs within Single React Informed Form
On putting two different select inputs within single Informed React form and changing value of one select input forces the select value to get changed on other select input also. 在将两个不同的选择输入放在单个Informed React表单中并更改一个选择输入的值时,也会迫使该选择值在其他选择输入上也发生更改。
Please find the sample code here. 请在此处找到示例代码。
<Form id="text-form" onSubmit={submittedValues=>this.onSave(submittedValues)}>
{formApi=>(
<div class="columns is-mobile">
<div class="column ">
<div className="textAlignLeft">
<label htmlFor="select-status">Y</label>
<Select field="status" id="select-status" className="selectStyle">
<Option value="" disabled>
Select One...
</Option>
{_.map(myData,(val) => {
return <Option value={val.y}>{val.y}</Option>
})}
</Select>
</div>
</div>
<div class="column ">
<div className="textAlignLeft">
<label htmlFor="sub-class">X</label>
<Select field="status" id="sub-class" className="selectStyle">
<Option value="" disabled>
Select One...
</Option>
{_.map(myData,(val) => {
return <Option value={val.x}>{val.x}</Option>
})}
</Select>
</div>
</div>
</div>
)}
</Form>
What I did : 我做了什么 :
this.setState({
countries: [{key: '', value: '', display: '(Kies een land)'}].concat(countriesFromApi).map((country) => <option key={country.key} value={country.value}>{country.display}</option>)
and then in the render method : 然后在render方法中:
<div className="col-md-4">
<Select field="Country" id="select-status">
{this.state.countries}
</Select>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.