jalik / js-form-parser Goto Github PK
View Code? Open in Web Editor NEWA utility to parse complex forms with minimum effort.
License: MIT License
A utility to parse complex forms with minimum effort.
License: MIT License
When parsing a checkbox with the data-type
property set to boolean
, my expectation is that a parsed form will either result in a true
or false
value for that field; with true indicating a checked state, and false being unchecked. This is not the case.
e.g.
<input name="abc" type="checkbox" data-type="boolean" value="true" checked>
console.log(parseForm(form, { nullify: false }));
Outputs:
{abc: null}
or
{abc: true}
When the checkbox is unchecked vs. checked, respectively. Per the docs,
Note: The boolean data-type will convert "1" and "true" to true, all other values are false.
We should be seeing either true or false, never null.
Is this expected functionality and is there a way to force an actual boolean result?
Given a single form element like:
<input name="contactNumbers[blocks][864536][fields][number]" type="text" value="[val]">
The parsed data ends up like:
{
...
contactNumbers: {
blocks: <Array with 864537 elements>
}
...
}
In the above example, the contactNumbers.blocks
array with a length of 864537
- almost all values are null
. The array index 864536
contains the correctly parsed object: fields.number
with a value in this case of "[val]"
.
When this object is converted to JSON with JSON.stringify()
for submission to the server, it ends up at approximately 4.3Mb.
Using version 2.0.5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.