germsvel / phoenix_test

MIT License
144 stars 20 forks source link

Fix checked checkbox being overridden by hidden input #68

Closed germsvel closed 4 months ago

germsvel commented 4 months ago

Resolves #https://github.com/germsvel/phoenix_test/pull/67

What changed?

From #67:

When submitting a form with a checkbox that has an accompanying hidden input (to populate the params when the checkbox is not checked), our current implementation grabs the value in the hidden input and ignores the later checkbox regardless of whether it is checked.

That's happening because our value is being overridden by the later inclusion of "pre-filled" inputs. The last put_form_data call in our Form's attempt to populate the data (meant to capture inputs with text or with no type) has a lot of exclusion CSS (i.e. :not()) which did not exclude hidden inputs.

We change our queries to be more explicit by splitting the query to grab text and default text inputs into two queries which do not have to exclude so many other types.

Co-authored-by: @totaltrash