0.4.36 • Published 5 years ago

formik-generator v0.4.36

Weekly downloads
151
License
MIT
Repository
-
Last release
5 years ago

WARNING

Before you use, please be aware of:

  • there is no guarantee that this library will be actively maintained
  • the software is provided "as it is"
  • please expect occasional bugs with different combinations of the json structure used
  • use on your own responsibility :)

Introduction

formik-generator is a library which allows you to generate forms from JSON input. It uses formik, react-select, react-datepicker and yup under the hood. You can play with formik-generator in your web browser with our live online playground.

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's dependencies:

npm install --save formik-generator

or

yarn add formik-generator

Usage

import React from 'react'
import { render } from 'react-dom'
import axios from 'axios'
import FormikGenerator from 'formik-generator'
import formStructure from './formStructure.json'

function onCancel() {
  console.log('cancel')
}

function onSubmit(values) {
  console.log(values)
}

function optionsGetter(url, query) {
  // this helper is required by AsyncCreatable field.
  // should return an array of strings, eg. ['yellow', 'green', 'blue']
  axios
    .get(url, { params: { query } })
    .then(response => response.data)
    .catch(err => console.error(err))
}

const initialValues = undefined // your initial values

const App = () => {
  return (
    <FormikGenerator
      formStructure={formStructure}
      initialValues={initialValues}
      onCancel={onCancel}
      onSubmit={onSubmit}
      optionsGetter={optionsGetter}
    />
  )
}

render(<App />, document.getElementById('root'))

Documentation

Full documentation with playgrounds available at: https://accelerated-digital.gitlab.io/formik-generator/

0.4.36

5 years ago

0.4.35

5 years ago

0.4.34

5 years ago

0.4.33

5 years ago

0.4.32

5 years ago

0.4.31

5 years ago

0.4.30

5 years ago

0.4.29

5 years ago

0.4.27

5 years ago

0.4.26

5 years ago

0.4.25

5 years ago

0.4.24

5 years ago

0.4.23

5 years ago

0.4.22

5 years ago

0.4.21

5 years ago

0.4.20

5 years ago

0.4.18

5 years ago

0.4.17

5 years ago

0.4.16

5 years ago

0.4.15

5 years ago

0.4.14

5 years ago

0.4.13

5 years ago

0.4.12

5 years ago

0.4.11

5 years ago

0.4.10

5 years ago

0.4.9

5 years ago

0.4.8

5 years ago

0.4.7

5 years ago

0.4.6

5 years ago

0.4.5

5 years ago

0.4.4

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago