0.2.2 • Published 7 years ago
react-vedora-form v0.2.2
React Vedora Form
The form generator for React JS that is easy to use, has been integrated with complete validation
Installation
npm i react-vedora-form
Usage
JSX
import React, { Component } from 'react'
import { FormPackage } from 'react-vedora-form'
class ExampleComponent extends Component {
constructor(){
super()
this.forms = [
{
'label': 'Example Field',
'name': 'field',
'type': 'text',
'format': 'input-text',
'rules': 'required|min_length[3]|max_length[8]',
}
]
}
onSubmitForm(valueForm){
}
render() {
return (
<FormPackage
forms={this.forms}
onSubmit={this.onSubmitForm.bind(this)}
/>
)
}
}
API
Props
Property | Type | Default | Description |
---|---|---|---|
forms | array | null | The list of setting for fields in the form |
onSubmit | function | undefined | The function that will be called when the submit button on the form is pressed and will get the return value of the form fill |
Validation Rules
Rule | Parameter | Description | Example |
---|---|---|---|
required | No | Returns FALSE if the form element is empty | - |
min_length | Yes | Returns FALSE if the form element is shorter than the parameter value | min_length3 |
max_length | Yes | Returns FALSE if the form element is longer than the parameter value | max_length12 |