import { validations } from 'form'
const { isEmail, minLen } = validations
const profileFormFields = [
{
name: 'name'
},
{
name: 'description',
inputType: 'textarea',
placeholder: 'Tell us all about it',
validation: minLen(10),
errorMessage: 'Please provide a longer description'
},
{
name: 'email',
validation: isEmail,
errorMessage: 'Please provide a valid email address'
},
{
name: 'favoriteColor',
label: 'Choose your favorite color',
inputType: 'select',
options: ['', 'red', 'green', 'blue']
},
{
name: 'animal',
inputType: 'radio',
options: ['dog', 'wildaboar']
},
{
name: 'isHungry',
inputType: 'checkbox',
label: 'Are you hungry?'
},
{
name: 'countries',
inputType: 'checkboxes',
options: [
'USA',
{ label: 'Vietnam', value: 'VN' },
{ label: 'Arigonia', value: 'AR' }
]
}
]
export default profileFormFields
import Form from 'form'
import profileFormFields from './profileFormFields'
const UserForm = () =>
<Form
fields={profileFormFields}
onSubmit={console.log}
/>
{
animal: 'wildaboar',
countries: ['USA'],
description: '',
favoriteColor: 'green',
firstName: 'Moonbean',
isHungry: true,
lastName: 'Sillers',
password: 'pass'
}