7.0.15 • Published 6 years ago

redux-form-generator v7.0.15

Weekly downloads
13
License
MIT
Repository
github
Last release
6 years ago

Form generator for redux-form and final-form

Generate bootstrap-form in your react application by providing json.

Version 6 is build from the ground up, so you know features are missing ;)

Final-form

Now you can also use Final-Form instead af redux-form

redux-form

import Form from 'redux-form-generator';

final-form

import {FinalForm as Form} from 'redux-form-generator';

Examples

Simple login form

FieldArray aka Complex

Migration

V0.1.x -> V6.x.x

  • Added property hortzontal (bool)
  • Renamed property fieldsNeeded -> fields (json)
  • Renamed property formName -> name (string)
  • Renamed Field radio/checkbox property searchable -> filter (bool)
  • Removed property checkKey
  • Removed property formKey
  • Removed property getActionState
  • Removed property clearActionState
  • Removed property formClass

Warning

Breaking changes

0.0x Release for use with react-bootstrap <= 0.28.x

0.1.x Release from use with react-bootstrap >=0.29.x

Installation

npm install --save redux-form-generator

File uploads are using react-plupload So if you need file upload please follow the instructions over there for installation

Example

The is a small example included, this example had no working backend Use with the chromebrowser, IE will fail in the example.

online

git clone https://github.com/lemonCMS/redux-form-generator.git
cd redux-form-generator/example
npm install
npm run dev

Usage

Define a const field function, later on in your component you call this function and you can pass extra params you can use in the fields definition. Like i needed my authorization token for the use with plupload.

export default function form(resource) {
  return ([
    {
      name: 'field_1',
      label: 'Field 1',
      helper: 'How are you today?',
      type: 'text',
      bsSize: 'large',
      placeholder: 'Field 1',
      addonBefore: '@',
      addonAfter: '@',
      labelSize: {
        md: 2
      },
      fieldSize: {
        md: 10
      }
    }]
  );
}

Put in your react render component the following code

<DynamicForm
	name="userEdit" <-- Name of your store 
	horizontal <-- Display fthe form horizontal  
	fields={fields()} <-- The field const function
	static <-- Show text version
	initialValues={{}} <-- Pass the initial values from your store 
	onSubmit={this.handleSubmit} <-- The submit function in your component to handle submit
	validate={(data) => { return {} }} <--Validation rules
/>

#Available types

##Button

{
    type: 'button',
    name: 'button',
    value: 'Button',
    onClick: () => {
      console.log('You clicked me');
    }
}

Submit

{
    type: 'submit',
    name: 'submit',
    value: 'Send'
}

Text

{
    name: 'field_1',
    label: 'Field 1',
    helper: 'How are you today?',
    type: 'text',
    bsSize: 'large',
    placeholder: 'Field 1',
    addonBefore: '@',
    addonAfter: '@',
    labelSize: {
        md: 2
    },
        fieldSize: {
        md: 10
    }
}

Password

{
    name: 'field_1',
    label: 'Field 1',
    type: 'password',
    bsSize: 'large',
    placeholder: 'Field 1',
    addonBefore: '@',
    addonAfter: '@',
    labelSize: {
        md: 2
    },
        fieldSize: {
        md: 10
    }
}

Select

{
  name: 'field_3',
  label: 'Field 3',
  type: 'select',
  bsSize: 'large',
  placeholder: 'Field 3',
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  },
  options: [
    {value: '1', desc: 'Value 1'},
    {value: '2', desc: 'Value 2'},
    {value: '3', desc: 'Value 3'},
    {value: '4', desc: 'Value 4'}
  ]
}

Radio

{
  name: 'field_4',
  label: 'Field 4',
  type: 'radio',
  placeholder: 'Field 4',
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  },
  options: [
    {value: 1, desc: 'Value 1'},
    {value: 2, desc: 'Value 2'},
    {value: 3, desc: 'Value 3'},
    {value: 4, desc: 'Value 4'},
    {value: 5, desc: 'Value 5'}
  ],
  chunks: 3,
  filter: true
}

Checkbox with multiple options, returns checkvalues as array

{
  name: 'field_6',
  label: 'Field 6',
  type: 'checkbox',
  bsSize: 'large',
  placeholder: 'Field 6',
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  },
  options: [
    {value: 1, desc: 'Value 1'},
    {value: 2, desc: 'Value 2'},
    {value: 3, desc: 'Value 3'},
    {value: 4, desc: 'Value 4'},
    {value: 5, desc: 'Value 5'}
  ],
  chunks: 3,
  filter: true
  
}

Checkbox with sing option, returns checkvalue as is

{
  name: 'field_6',
  label: 'Field 6',
  type: 'checkbox',
  bsSize: 'large',
  placeholder: 'Field 6',
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  },
  options: [
    {value: 1, desc: 'Value 1'},
  ],
  chunks: 3,
  filter: true,
  single: true
}

Textarea

{
  name: 'field_5',
  label: 'Field 5',
  helper: 'How are you today?',
  type: 'textarea',
  placeholder: 'Field 5',
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  }
}

Rte

Tinymce editor, so for configuration options tinymce

{
  name: 'field_8',
  label: 'Field 8',
  helper: 'How are you today?',
  type: 'rte',
  placeholder: 'Field 8',
  conf: {
    readonly: true
  },
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  }
}

Input with dropdown

{
  name: 'field_7',
  label: 'Field 7',
  type: 'text',
  bsSize: 'large',
  placeholder: 'Field 7',
  buttonAfter: {
    name: 'field_7_1',
    label: 'Field 7_1',
    type: 'dropDown',
    items: [
      {value: '1', desc: 'Value 1'},
      {value: '2', desc: 'Value 2'},
      {value: '3', desc: 'Value 3'}
    ]
  },
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  }
}

Resource

Load data from overlay with its own store. See the example on how to implement

{
  name: 'field_9',
  label: 'Field 9',
  type: 'resource',
  callResource: resource,
  list: [
    {value: 1, desc: 'Item 1'},
    {value: 2, desc: 'Item 2'},
    {value: 3, desc: 'Item 3'}
  ]
}

Plupload

Upload files with plupload See for more configuration options plupload

{
  name: 'field_10',
  label: 'Field 10',
  type: 'plupload',
  conf: {
    id: 'plupload',
    runtimes: 'html5',
    multipart: true,
    chunk_size: '1mb',
    url: '/',
    multi_selection: false,
    flash_swf_url: '/plupload-2.1.8/js/Moxie.swf',
    autoUpload: true,
    headers: {Authorization: 'Bearer laravelAutToken'}
  }
}

DateTime

See for more configuration options plupload

{
  name: 'field_11',
  label: 'Field 11',
  type: 'dateTime',
  placeholder: 'DateTime',
  bsSize: 'large',
  display: valueOf // MomentJs function which returns the value you desire. [See momentjs docs](https://momentjs.com/docs/#/displaying/)
  conf: {
    format: 'x',
    inputFormat: 'YYYY-MM-DD'
  },
  labelSize: {
    md: 2
  },
  fieldSize: {
    md: 10
  }
}

Success

Show this message when the form has been succesfully send.

{
  type: 'success',
  message: 'The form has been send'
}

Error

Show this message when there are errors

{
  type: 'error',
  message: 'There are errors, please check the form.'
}

Misc

Display multiple fields in one row

row: {
  col: [
    {
      md: 4,
      children: [
        {
          name: 'plain',
          type: 'plain',
          value: '<div class="pull-right">Name*</div>'
        }
      ]
    },
    {
      md: 3,
      children: [
        {
          name: 'firstname',
          type: 'text',
          placeholder: 'Firstname',
          fieldSize: {md: 12}
        }
      ]
    },
    {
      md: 5,
      children: [
        {
          name: 'lastname',
          type: 'text',
          placeholder: 'Lastname',
          fieldSize: {md: 12}
        }
      ]
    },
  ]
}

Display messaged in your own grid layout.

{
      row: {
        hideOnStatic: true,
        col: [
          {
            md: 10, mdOffset: 2, children: [
              {type: 'success', message: 'The form has been send'},
              {type: 'error', message: 'There are errors, please the the form.'}
            ]
          },
          {hideOnStatic: true, md: 10, mdOffset: 2, children: [{type: 'submit', name: 'submit', value: 'versturen'}]}
        ]
      }
    }

Dependecies

Help wanted

Help wanted to make this package stable!

PM2

Go into the example directory. and run

pm2 start "/usr/bin/npm" -f --name "app-redux-form-generator" -- run start
7.0.15

6 years ago

7.0.14

6 years ago

7.0.13

6 years ago

7.0.12-beta

7 years ago

7.0.11-beta

7 years ago

7.0.0-beta10

7 years ago

7.0.0-beta9

7 years ago

7.0.0-beta8

7 years ago

7.0.0-beta7.2

7 years ago

7.0.0-beta7.1

7 years ago

7.0.0-beta7

7 years ago

7.0.0-beta6

7 years ago

7.0.0-beta5

7 years ago

7.0.0-beta4

7 years ago

7.0.0-beta3s

7 years ago

7.0.0-beta2

7 years ago

7.0.0-beta1

7 years ago

6.0.56

7 years ago

7.0.0-beta-1

7 years ago

7.0.0-beta

7 years ago

6.0.55

7 years ago

6.0.54

7 years ago

6.0.53

7 years ago

6.0.52

7 years ago

6.0.51

7 years ago

6.0.50

8 years ago

6.0.48

8 years ago

6.0.47

8 years ago

6.0.46

8 years ago

6.0.45

8 years ago

6.0.44

8 years ago

6.0.43

8 years ago

6.0.42

8 years ago

6.0.41

8 years ago

6.0.40

8 years ago

6.0.39

8 years ago

6.0.38

8 years ago

6.0.37

8 years ago

6.0.36

8 years ago

6.0.35

8 years ago

6.0.34

8 years ago

6.0.33

8 years ago

6.0.32

8 years ago

6.0.31

8 years ago

6.0.30

8 years ago

6.0.29

8 years ago

6.0.28

8 years ago

6.0.27

8 years ago

6.0.26

8 years ago

6.0.24

8 years ago

6.0.23

8 years ago

6.0.22

8 years ago

6.0.21

8 years ago

6.0.20

8 years ago

6.0.19

8 years ago

6.0.18

8 years ago

6.0.17

8 years ago

6.0.16

8 years ago

6.0.15

8 years ago

6.0.13

8 years ago

6.0.12

8 years ago

6.0.11

8 years ago

6.0.10

8 years ago

6.0.9

8 years ago

6.0.8

8 years ago

6.0.7

8 years ago

6.0.6

8 years ago

6.0.4

8 years ago

6.0.3

8 years ago

6.0.2

8 years ago

6.0.1

8 years ago

0.0.32

8 years ago

6.0.0

9 years ago

0.1.32

9 years ago

0.1.31

9 years ago

0.1.30

9 years ago

0.1.29

9 years ago

0.1.28

9 years ago

0.1.27

9 years ago

0.1.26

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.20

9 years ago

0.1.19

9 years ago

0.1.16

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.0.31

9 years ago

0.0.30

9 years ago

0.0.29

9 years ago

0.0.28

9 years ago

0.0.27

9 years ago

0.0.26

10 years ago

0.0.25

10 years ago

0.0.24

10 years ago

0.0.23

10 years ago

0.0.22

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago