I am facing a simple issue yet not getting it's solution so i have posted my concern over here. The thing is on selecting multiple options from select box i am not able to save those data into DB. Getting the success message but data not stored into DB.
updateData = () => {
var optionIds = this.state.selectedId;
console.log(optionIds);
api.request({url: `/update-data/${this.props.row.id}`, method: 'put', data: {[this.field]: this.state.selectedId } })
.then(res => console.log(`Data ${this.field} have been updated`)
}
handleChange = (selectedId) => {
this.setState({ selectedId });
}
render() {
const { selectedId } = this.state;
return (
<Select
defaultValue={this.props.defaultValue.id}
value={selectedId}
onChange={this.handleChange}
options={options}
isMulti
/>
<button type='button' className='btn btn-primary' onClick={this.updateData}>Save</button>
);
}
selectedId:
[
0: {value: 1, label: "data1"}
1: {value: 2, label: "data2"}
]
No responses yet.