Nevertheless! Party Metaphorically
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    formulairepublic

    README

    Developing

    Install

    #!bash 
     
    npm install formulaire

    (formulaire uses lodash)

    Using formulaire

    #!javascript
     
    var formulaire = require('formulaire');
     
    var myForm = formulaire({
        //options
    });
     

    Returns cool html code ready to use

    API Options

    No default values (pending to do)

    Option Value
    formClass STRING
    formId STRING
    action STRING
    method POST | GET
    fieldClassWrapper STRING Equivalent class to wrapper of the field
    fieldClass STRING Class definition to inputs
    submit.type link | button | input
    submit.clase STRING
    submit.href STRING
    submit.onclick STRING
    submit.field STRING
    field.type text | password | color | date | datetime-local | email | month | number | range | search | tel | time | url | week | radio | checkbox | select | textarea

    Code Example

    #!javascript
     
    var formulario = formulaire({
            formClass : 'form',
            formId : 'formulario_ID',
            action: '/send',
            method: 'post',
            fieldClassWrapper: 'form-group',
            fieldClass: 'form-control',
            submit: { 
                type: 'link',
                clase: 'btn btn-primary sender',
                href: 'javascript:void(0)',
                onclick: null,
                value: 'Enviar'
            },
            fields: {
                name: { type: 'text', required: true },
                surname: { type: 'text', required: true},
                email: { type: 'email', required: true},
                age: { type: 'number'},
                country: {
                    type: 'select',
                    default: 'Select your country',
                    required: true,
                    options: {
                        spain: { label: 'Spain', selected: true},
                        usa: { label: 'USA'}
                    }
                },
                sex: {
                    type: 'radio',
                    options: {
                        m: { label: 'Male'},
                        f: { label: 'Female'}
                    }
                },
                preferences: {
                    type: 'checkbox',
                    options: {
                        soccer: { label: 'Soccer', checked: true },
                        basket: { label: 'Basket'},
                        tennis: { label: 'Tennis'},
                        volley: { label: 'Volley'},
                        hockey: { label: 'Hockey'},
                    }
                },
                observations: { type: 'textarea', required: true }
            }
        });
     

    Now, you can use an JSON file to define the form

    #!javascript
    var defForm = require('./json/form_example.json');
    var formulario = formulaire(defForm);
     

    install

    npm i formulaire

    Downloadslast 7 days

    2

    version

    0.0.8

    license

    MIT

    repository

    bitbucket.org

    last publish

    collaborators

    • avatar