1.0.13 • Published 5 years ago

easy-form-manager v1.0.13

Weekly downloads
64
License
MIT
Repository
github
Last release
5 years ago

easy-form-manager

Simple, Fast, MobX-State-Tree powered form manager Live Demo

Contents

Installation

  • NPM: npm install easy-form-manager --save
  • Yarn: yarn add easy-form-manager

Getting started

<Form> is a wrapper component automatically inject value and listener to each field contained with fieldid atributte added.

propdescriptionrequired
onSubmitCallback return field values required a submit type button.optional
validationCallback function expect return true or false.optional
fieldidAtributte required must be added to each field.required
import { Form } from "easy-form-manager"
//...

render(){
  return(
    <Form 
      onSubmit={(values)=> { /* do something with the values */ }} 
      validation={(values) => /* validate values and return true or false */}
    > 
      <label>This is a field</label>
      <input fieldid="field-id" />
    </Form>
  )
}

<ConditionalRender> is a wrapper component to hide or render the children

propdescriptionrequired
conditionCallback return field values and expect true or falseoptional
import { Form } from "easy-form-manager"
//...

render(){
  return(
    <Form> 
      <ConditionalRender condition={(values)=> /* add some condition as values.fieldid === "something" */ ? true : false}>
        <MoreFields />
        <YepEvenMoreThanOne />
      </ConditionalRender>
    </Form>
  )
}

Examples

To run the examples:

  1. clone this repository
  2. navigate to the demo folder (e.g. /demo)
  3. run yarn install and yarn start

or check the Live Demo page

Api overview

signature
values()Function, return field values
getFieldValue(fieldid) => fieldid.value)Return an specific field value
setValue(fieldid, value)Set a value to an specific field
1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago