Giter Site home page Giter Site logo

formidable-vue's Introduction

Formidable-Vue

A Vuejs form helper

Installation

Install it via npm with npm i formidable-vue

Usage

Add Formidable as a plugin in your main Javascript file:

import Formidable from 'formidable-vue';
Vue.use(Formidable);

You can set optional settings in the parameter during inizialization:

import Formidable from 'formidable-vue';
Vue.use(Formidable,{
  template        : 'vuetify', //Use Vuetify template
  formidableName  : 'formidable', //Name of the main formidable field
  fieldName       : 'form-field', //TBD
  fieldResolver   : require('./Fields/'+style+'/index').default //TBD
});

In your page

    <div id="app">
        <formidable
                action="destination-url"
                method="post"
                :fields="fields"
                @submit="onSubmit"
                @error="onError"
                >
        </formidable>
    </div>
    <script>
        new Vue({
            el:'#app',
            data:function(){return {
                fields:[
                    {name:'name',label:'Name',type:'text',placeholder:'username',required:true},
                    {name:'email',label:'Email',type:'email',required:true},
                    {name:'password',label:'Password',type:'password',placeholder:'',minLength:6},
                    {name:'roles',label:'Roles',type:'select',placeholder:'',values:{1:'one',2:'two'},multiple:true ,value:[1,2]},
                    {name:'active',label:'Active',type:'checkbox',placeholder:'',value:1},
                ]
            };},
            methods:{
                onSubmit(r){
                    console.log('onsubmit',r);
                },
                onError(e){
                    console.log('onError',e);
                }
            }

        });
    </script>
    

Templating

Formidable integrates a template manager so you can easly switch between css frameworks without adapting or rewriting your code. The template you want to use is specified in the plugin initialization, via the template option; each template is located under a folder with it's name, each folder has a index.js that resolves all the input types.

formidable-vue's People

Watchers

James Cloos avatar  avatar Kim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.