Hi @restive pivot , I'm back! Following your recommendation above I have the following:
<SelectInput
path={p}
name='l'
label='logic'
options={options.map(option => option...)}
onChange={e => handlePrerequisiteChange(e, path)}
/>
The above doesn't persist between refreshes.
The following sometimes works when another field is updated:
<select
title='prerequisite'
value={selectedOption}
onChange={e => handlePrerequisiteChange(e, path)}
>
{options.map((option, index) => (
<option key={`r-${index}`} value={`${option.question}_${option.answer}`}>
{`${option.question}_${option.answer}`}
</option>
))}
</select>
-
I'm still using useFormFields, I can't see how to make use of useFields (without violating react hook laws). How could I update each dropdown with useFields? My implementation is below
-
Changing an option in my select won't trigger the clean/dirty flag for saving/publishing changes but sometimes persists when other fields change
Hopefully the content below will help paint a picture of what I'm working with and why I chose useFormFields:
const generateOptions: (fields: any) => string[] = fields => {
const numberOfPages = pageState.pages.value
const questionCombination = [...Array(numberOfPages).keys()].flatMap(pageNo =>
getAnswerOptionsFromAnswerTypes(
fields[`pages.${pageNo}.content.questions.0.answerType.0.blockType`],
).map<ConditionalLogicOptions>(option => ({
question: fields[`pages.${pageNo}.content.questions.0.text`].value,
answer: fields[`pages.${pageNo}.content.questions.0.answerType.0.${option}`]?.value || '',
})),
)
return questionCombination
}