Closed mhemesath closed 13 years ago
weird, I've never seed the hidden checkbox technique, seems a little hackish but it is slightly annoying that browsers do not submit all field values, but it seems like it would be a big hack to support it within a query-string module, especially because it's pretty important that we maintain multiples without [] to be an array, seems to be the norm
Yeah, I'll admit when I was first exposed to how the Rails bodyparser works, it did throw me off. I think its fair to leave it how it is, changing it at this point is slightly non-passive anyway hahah.
yeah that's pretty crazy
Argh, I was actually expecting this behavior and was all kinds of annoyed trying to figure out how to do this. Most other frameworks including PHP, .NET and Rails overwrite the values of inputs with the same name.
Not sure why qs
handles it this way. Is there any way to get the overwriting behavior? Would make for much cleaner logic when parsing checkbox values.
This isn't an issue, more of a question on how to handle behavior with current functionality. My problem is I would like to detect when a checkbox is unchecked. Currently if the value is not checked, it is not submitted, and thus the attribute corresponding to that checkbox is not updated. In Rails, I would do this like so:
Rails would interpret this as:
Node Querystring interprets this as:
I think both ways make sense. Rails requires myCheckbox[] if I really want a list submitted. But node-querystring definitely has closer behavior to what would be expected with inputs with similar names to be submitted. With that said, is there a way to set a default state of a checkbox to get submitted if its not checked?
I know radio buttons would solve this problem, but I would like to use checkboxes in a lot of cases and detect when they are unchecked. Thoughts?
Quick Example