1.0.11 • Published 6 years ago

@ibberson92/reactforms v1.0.11

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Reactive Forms

This module is largely completed. That said, many more tests need writing and various files need refactoring. Much of this work exists in the development branch and will comprise the V2 release.

Basic Usage

The following example illustrates the most basic implementation of this module. Note the parent components <Config /> and <Notification />: these are absolutely necessary, as explained in the documentation below (coming soon).

    import Config, { Notification, Form, Field } from '@ibberson92/reactforms';
    
    const saveFormDataToConsole = formData => {
        console.log(formData);  
    };
    
    const alertOnComplete = data => {
        alert('Call done!');  
    };
    
    export default props => (
        <Config>
            <Notification>
                <Form service={saveFormDataToConsole} callback={alertOnComplete} submit="Save">
                    <Field name="firstField" label="My First Field" type="text" required />
                </Form>
            </Notification>
        </Config>
    );

Custom Field Props

NameValue(s)RequiredNotes
Type"text", "phone", "email", "password", "credit", "textarea", "richtext", "date", "time", "select", "radio" or "checkbox"YesAccepts any value; however, many come with pre-configured settings.
Optionsarray or object (see snippet below)YesApplies to select and radio types.
NamestringYesUses as the FormData key on form submission.
Valuestring, integer or booleanNoProvides a default value for the field.
RequiredbooleanNoMarks as a required field.
LabelstringNoDisplays a <label></label> tag in the output.
DescriptionstringNoRenders fine print for the field to expound on the label.
    /**
    * @NOTE
    * Example of the "options" props value.
    * The simple object applies to select and radio fields alike.
    * The complex object applies to select exclusively.
    */

    let simpleSelectOptions = [{
        name: 'Simple Select',
        value: 1
    }];
    
    let groupSelectOptions = {
        groups: [{
            name: 'My First Group', 
            options: simpleSelectOptions
        }]  
    };
1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago