At some point, a page's default data (parsed in Form) would become part of the ActiveForm 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 from form.form_data. We should not copy it and keep track of it there.
click_button, submit, and anything else that triggers changes (like phx-change) should know to combine form.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.
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.