#How to handle mapped inputs formdata?
4 messages · Page 1 of 1 (latest)
{initialData.value?.selectors.map((option, index) => (
<input type="checkbox" name={`option-${index}`} value={option.id} />
))}
There must be a better way?
currently it uses dot notation to create objects and [] for an array. note that currently it doesn't support an array of objects. So you could do:
{initialData.value?.selectors.map((option, index) => (
<input type="checkbox" name={`options.${index}`} value={option.id} />
))}
and that would result as:
{
options: {
1: true,
2: true,
3: false
}
}```
iirc