<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
// ./seed/index.js
import * as yup from 'yup'
const seed = [{ <-- important: each object in the array represents an input field in the form
id: 'identifier', <-- important: this name is being used to setup the initial values for formik state
name: 'identifier',
label: 'Email',
type: 'email',
placeholder: 'Email',
autoComplete: 'email'
}, {
id: 'password',
name: 'password',
label: 'Wachtwoord',
type: 'password',
placeholder: '********',
autoComplete: 'current-password',
helperText: 'Wachtwoord vergeten?'
}]
const loginValidationSchema = yup.object().shape({
identifier: yup
.string()
.email()
.required('Email must be filled in'),
password: yup
.string()
.min(0)
.required('Password is required')
})
export { seed, validationSchema }
import React, { Component } from 'react'
import { CustomForm } from 'release-contracts-ui-components'
import { seed } from './seed'
class Example extends Component {
render () {
return (
{/* This creates a form with 2 fields: username and password. It also contains a custom onSubmit callback */}
<Form title='form title' fields={seed} validationSchema={validationSchema} onSubmit={() => console.log('submitting')} />
)
}
}