Giter VIP home page Giter VIP logo

react-forms's Introduction

Luvago React Forms

This package provides containers to work with forms, inputs, and custom input-components.

<Form formName="test-form">
  <Field formName="test-form" fieldName="user" defaultValue={this.data.user || {firstName: 'John'}}>
    <input type="text" name="firstName" />

    <FieldError />
  </Field>
  <Field formName="test-form" fieldName="dob" defaultValue={this.data.dob}>
    <InputComponent />
  </Field>
</Form>

Form Attributes

  • formName - used as the key in the state to save the current form
  • multiForm - set to true to turn off clearing on change

Field Attributes

  • formName - used as the key in the state to save the current form
  • fieldName - used as the key in form.fields to save the current field
  • errorClassName - added to classes when the current field has an error default: validationError

Field Children Attributes

  • onChange - must be called in custom components with this.props.onChange(event, data)
    • if data is undefined, the Field component will try to use event.target.value (so this works with almost every native input out of the box)
  • processFunc or data-processFunc - gets called with the same signature as onChange, but the returned value will be used instead of the actual element.value
    • example: <input type="text" name="firstName" processFunc={(event, value) => value.toUpperCase()} />
    • also works with promises, and will change the value in the state once the promise resolves
  • validators - array of validators from FormValidators which will be applied to the field onChange or onBlur depending on the input type
  • classError

License

MIT

react-forms's People

Watchers

James Cloos avatar Joey Figaro avatar  avatar

Forkers

evalcraciun

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.