Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Latest commit

 

History

History
66 lines (49 loc) · 1.53 KB

README.md

File metadata and controls

66 lines (49 loc) · 1.53 KB

FV React Form

Flexible React form with validation.

Installation

To install into your project, run this command.

npm install --save fv-react-form

Usage

import Form from "fv-react-form";

class Example extends Component {
    render() {
        return (
            <Form
                // Called if validation passes
                action={form => console.log(form)}
                method="POST"
                name="login"
                rules={{
                    name: 'required'
                }}
                // Called every time form is submitted
                onSubmit={form => console.log(form)}
            >
                {/* Show all errors */}
                <Form.Errors/>
                
                <Form.Group>
                    <Form.Input type="name" name="name" placeholder="Name"/>
                    {/* Show field error */}
                    <Form.Error field="name"/>
                </Form.Group>
                
                <Form.Button type="submit">Submit</Form.Button>
            </Form>
        );
    }
}

Examples

To build examples, run this command.

npm run build-examples

Contributing

All contributions are welcome. Before starting work on your contribution, please contact the maintainer to make sure no one else is working on the same contribution as you. To develop examples, run this command.

npm run dev-examples

If you add a new example, make sure to update the compiler file webpack.mix.js with your new example file.