🛠️ Fix active form vs form data loading #134
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #105
What changed?
At some point, a page's default data (parsed in
Form
) would become part of theActiveForm
form data.That meant that if the data on the page changed, the stuff that had been filled in on a previous form action would prevail because it was acting as part of the "active form" data.
This is the way this should work (done in this commit):
ActiveForm
should ONLY keep track of fields that have been filled in. The rest of the data to submit should come fromform.form_data
. We should not copy it and keep track of it there.click_button
,submit
, and anything else that triggers changes (likephx-change
) should know to combineform.form_data ++ ActiveForm.form_data
before sending it to the server.We should probably keep track of form data in a map instead of a list of tuples. We used to keep it in a nested map, and we wanted to flatten it. We should still keep it flat, but we should make it a map. That's left for future work since it's not affecting the current fix.
Test notes
We move common form helper behavior tests out of fill_in and into a shared tests group.