Socket
Socket
Sign inDemoInstall

form-input-serialize

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    form-input-serialize

Serialize/Deserialize form input, and lookup


Version published
Weekly downloads
9
Maintainers
1
Created
Weekly downloads
 

Readme

Source

form-input-serialize

Build Status

form-input-serialize provides helper functions to retrive form props and form values

inputPropsLookup(fieldsProps, fieldName)

ArgumentTypeExample
fieldsPropsobject{name: {type: 'text'}, email: {type: 'email'}}
fieldNamestringname, email[0], email[1]

####returns object: props, e.g. {type: 'text'}

####e.g.

const fieldsProps = {
  name: { type: 'text' },
  age_group: {
    type: 'select',
    size: 4,
    options: []
  }
  address: {
    type: 'nested',
    fields: {
      street: {
        type: 'text'
      }
    }
  }  
};
const fieldName = 'address[0][street]';

const props = inputPropsLookup(fieldsProps, fieldName);
// <input name={fieldName} {...props} />

formInputsSerialize(form)

formInputsSerialize(form)  
ArgumentTypeExample
formDOMNodeform element

####returns object. serialized, e.g. {type: 'text'}

####e.g.

// <form ref={f => this.form =f}><input name="message" value="hello"/></form>

const values = formInputsSerialize(this.form);
// { message: 'hello' }

inputValueLookup(values, fieldName)

ArgumentTypeExample
valuesobject{address: [ {zip: '55555'} ]}
fieldNamestringaddress[0][zip]

####returns any. input value, e.g. {type: 'text'}

####e.g.

const values = {
  name: 'Ali',
  age_group: '31-40'
  address: {
    0: {
      street: '13 Calle 49a'
     }
};
const fieldName = 'address[0][street]';

const value = inputValueLookup(values, fieldName);

// <input name={fieldName} value={value} />

Keywords

FAQs

Last updated on 17 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc