0.4.0 • Published 7 years ago

simple-form-creator v0.4.0

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

simple-form-creator

Creates a DOM form from your options object using vanilla js

Installation

Simple form creator is available as an npm package.

npm install simple-form-creator

Usage

Include the module in your script.

import simpleFormCreator from 'simple-form-creator';

Create an object containing the form's settings:

  • formId (form's id, if not provided, defaults to random string of characters)
  • action (action url, if not provided, defaults to empty string
  • method (GET, POST, ... - if not provided, defaults to POST)
  • formData (data to fill the form with, if not provided, defaults to empty object)

Example:

const formObject = {
    'formId': 'myNewForm123',
    'action': 'http://mydomain.com/example-post',
    'method': 'POST',
    'formData': {
        'firstName': 'John',
        'lastName': 'Smith',
        'phoneNumber': '+123456789'
    }
}

Now create the form

const form = simpleFormCreator(formObject);

Your brand new form is set up. Now you can use it make form post (or get) submits, append it to DOM or what not. Just one example:

form.submit();

Contributing

Getting started

  1. Fork the Simple-form-creator repository on Github
  2. Clone your fork to your local machine git clone git@github.com:<yourname>/simple-form-creator.git
  3. Create a branch git checkout -b my-topic-branch
  4. Make your changes and add tests for them, lint, test then push to to github with git push --set-upstream origin my-topic-branch.
  5. Visit github and make your pull request.

Scripts

  • Install npm install
  • Lint npm run lint
  • Test npm test
  • Build npm run build

Coding style

Please follow the coding style of the current code base. Simple-form-creator uses eslint, so if possible, enable linting in your editor to get realtime feedback. The linting rules can be run manually with npm run lint.

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago