1.1.4 • Published 11 years ago

serialize-form v1.1.4

Weekly downloads
7
License
-
Repository
github
Last release
11 years ago

form-serializer

ender add form-serializer

var serializeForm = require('form-serializer').serializeFormObject
  , toNativeTypes = true
  , obj
  ;

obj = serializeForm('form#save-data', toNativeTypes);
// `true` means "try to convert to native types"
// Supported Types: Numbers, Boolean, and null

console.log(obj);

API

Okay, so serialize is a terrible prefix. jQuery talked fancy to me. I got confused!

serializeing a form, in this case, means to go from DoM to JavaScript, not from Object to Text.

An optional second parameter will cause the values to be typecasted. Supported Types: Numbers, Boolean, and null.

  • serializeFormObject

    • does not allow duplicate keys - [name=foobar]
    • does turn [name="waldo[]"] into an array

          {
              "foobar": "baz"
            , "grault": "garply"
            , "waldo": ["qux", "quux"]
          }
  • serializeFormArray

    • true representation of the form

          [
              {
                  "name": "foobar"
                , "value": "baz"
              }
            , {
                  "name": "waldo[]"
                , "value": "qux"
              }
          ]

License

Copyright AJ ONeal 2011

This project is available under the MIT and Apache v2 licenses.

1.1.4

11 years ago

1.1.3

11 years ago

1.1.2

11 years ago

1.1.1

12 years ago

1.1.0

13 years ago

1.0.1

13 years ago