0.2.10 • Published 5 years ago

@nollavpat/form-template v0.2.10

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

Build Status Coverage Status

form-template

A module that template forms.

Installation

npm i -S @nollavpat/form-template

Usage

const {
  createTextField,
  createRadioButton,
  createCheckbox,
  createFormTemplate,
} = require('@nollavpat/form-template');

// create a template
const myTemplate = createFormTemplate('Application Form');

// create fields
const lastname = createTextField('Lastname', { placeholder: 'Enter Lastname' /* defaults to an empty string */});
const sex = createRadioButton('Sex', ['male', 'female'], { defaultValues: [0] /* defaults to [0]  */ })
const hobbies = createCheckbox('Hobbies', ['sleeping', 'eating', 'playing'], { defaultValues: [0, 1] /* default to an emptu array */ })

// add fields to a template
myTemplate.addComponent(lastname);
myTemplate.addComponent(sex);
myTemplate.addComponent(hobbies);

// remove a field
myTemplate.removeComponent(0); /* example on removing the lastname */

myTemplate.getComponents();
/*
* return an object
* {
*   isValid: Boolean,
*   raw: String,
*   toString: Function,
*   errors: []
* }
*/
0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.1.0

5 years ago