brainfoolong / form-data-json

A zero dependency, cross browser library to easily get or set/manipulate form input values as/from a json object.
https://brainfoolong.github.io/form-data-json
MIT License
60 stars 10 forks source link

Support for repacing empty array #28

Closed fglueck closed 2 years ago

fglueck commented 2 years ago

New Option "emptyArrayValue", if set it will place into empty array. In case for use with jquery ajax or some else wich skipping empty arrays.

brainfoolong commented 2 years ago

Thanks for your commit. But i'm not a big fan of this. This feature would exist to fix problems from other tools in the chain. You effectively simulate data that probably never exist as a field name in the form, which is not the goal of this library. This specific problem should be solved on the receiving end in this case. So i will not merge this, sorry. But thanks again for using it and trying to improve it.

fglueck commented 2 years ago

Sorry in my case it is not possible to resolve this an receiving end. How I can check the difference between that the element is sending "empty" or it is not sending? Because if some elements not sended, a default is used. Is the element received then the received value is used. How do you fixing that problem on your sites?

brainfoolong commented 2 years ago

I am not entirely sure what you trying to ask.

An empty text field is always an empty string in the result. An unchecked checkbox is by default not in the result, unless you enable uncheckedValue option.

fglueck commented 2 years ago

there is now problem with checkboxes, the problem is and if you don't choose an element. How I can split this pull request in two different? I can't find any button to do that on github.

brainfoolong commented 2 years ago

I cant split it. You must

For question and problems unrelated to any changes you make, please create a new issue where we can talk about. This pull request now get's really clunkered.

brainfoolong commented 2 years ago

PS: You don't have to update README. I will do that and most of the things will be automatically created on release creation.

brainfoolong commented 2 years ago

PPS: Und falls du willst, können wir auch in Deutsch weitermachen... Ist vielleicht einfacher dann für dich zu erklären.

fglueck commented 2 years ago

das macht es jedenfalls einfacher :-)

fglueck commented 2 years ago

OK, die Änderungen habe ich auch zurück genommen, bleibt jetzt nur das Problem das "leere"