Hi. I'm trying to create a multiple select form. But when I submit, only one option is saved into the array. I'm getting options from locations collection, and I'm submitting the form to the categories collection.
const handleInputChange = (e) => {
setCategory({ ...category, [e.target.name]: e.target.value });
};
return (
<div>
<form onSubmit={handleSubmit}>
<div className='form-group'>
<select
name='location'
onChange={handleInputChange}
size={locations.length}
className='form-control'
multiple
>
{locations.map((location) => (
<option value={location.title}>
{location.title}
</option>
))}
</select>
</div>
<button>Add</button>
</form>
</div>
);