I have a form that conditionally displays inputs.
What I have to do is display a table with values taken from a search of a database which is in a form. I have this part down, but the problem is saving it. I have to use react-hook-form getValues() to get the values of the form, including what is displayed on the table. To do this, I created hidden inputs with default values of what I need to save. This part works, but the problem occurs when the condition is no longer met, for some reason it still has the values of these inputs saved even though they should not exist.
Ex/
condition ? (
<Controller
controllerstuff....
<input value="tabledata" hidden/>
/>
) : (
<Controller
controllerstuff...
<input value="overwrite other stuff" hidden/>
/>
)
So, how can I overwrite/remove these values I do not need or what would be the best way to save the values from the search using getValues()? Thanks in advance.