Fix: Omit hidden input before checkbox group - #314
Conversation
22300cc to
462f68f
Compare
| nil -> | ||
| data ++ new_entries | ||
|
|
||
| first_index -> |
There was a problem hiding this comment.
This is a bit of a crux to handle multiple fields with same name.
|
Thanks for the work @ftes! I was really hoping we wouldn't have to revert back to lists for To your comment:
I've been wondering if there's a way to do that. In LiveViews, we might not need to keep track of FormData. In dead views, maybe? But even then, I wonder if when we submit the form, we don't use In any case, this is fixing an issue, and doesn't seem to break other things, so I'm gonna go ahead and merge it. |
Omit hidden 'reset' input that appears before checkbox group if any checkboxes are checked.
What changed?
Why make these changes?
A hidden input before a checkbox group can be used to reset the value if all checkboxes are unchecked.
However, if checkboxes are checked, then the hidden input should be effectively ignored.
Plug/Phoenix can handle this if the field values arrive in DOM order.
In forms like:
PhoenixTest previously collected controls by selector category and stored
FormDatain a map. That lost DOM order and collapsed repeated field names, which could cause the hidden scalar entry to interfere with the checkbox array payload.This PR is only a partial improvement. The ideal solution would be to submit form data in the exact DOM order a browser would, end to end.